msg['from'] = mail_user msg['subject'] = 'this is a python test mail' try: s = smtplib.SMTP() s.connect(mail_host)
#!/usr/bin/env python # coding=utf-8 import socket s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#登陆邮箱 pwd = ''#邮箱密码 to = [''] #发送的邮箱 with open('D:\\Python源码\\city.txt','r') as f: a = f.read() station =
from PIL import Image, ImageFilter, ImageOps img = Image.open('C:\\Users\\hengli\\Pictures\\lovewallpaper\\214926-106.jpg') def dodge(a, b, alpha): return min(int(a*255/(256-b*alpha)), 255) def draw(i
txt中每行一个ip地址和端口号,代码可循环监控这些ip地址的指定端口是否正常 #!/usr/bin/env python # -*- coding: gbk -*- import socket,time while
python检测远程udp端口是否打开 import socket import threading import time import struct import Queue queue = Queue
python判断远程端口是否打开,下面的代码判断指定网站的80端口是否打开 import socket sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#!/usr/bin/env python 'makeFile.py -- create a file' import os ls = os.linesep # get filename while True:
>>> import os >>> os.path.exists('d:/assist') True >>> os.path.exists('d:/assist/getTeacherList.py') True >>> os.path.isfile('d:/assist') False >>> os.path.isfile('d:/assist/getTeacherList.py') True >
利用socket包中的gethostname函数获取机器名之后,再调用gethostbyname函数获取机器的IP地址。 import socket def print_machine_info(): host_name = socket.gethostname() ip_address = socket.gethostbyname(host_name) print "Host name: %s"
exif-py是一个纯python实现的获取图片元数据的python库,官方下载地址: http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF
Tkinter, PIL and data_stream tested with Python27 and Python33 by vegaseat 01mar2013 ''' import io # allows
wx.Sound(fileName, isResource=False) tested with Python27 and wxPython291 by vegaseat 25jul2013 ''' import
import ftplib ftp = ftblib.FTP("ftp.yourServer.com") ftp.login("username", "password") filename = "index.html" ftp.storlines("STOR " + filename, open(filename)) filename="app.exe" ftp.storbinary("STOR
# -*- coding: utf-8 -*- #导入三个模块 import Image,ImageDraw,ImageFont import random import math '''基本功能''' #图片宽度 width = 100 #图片高度 height = 40 #背景颜色 bgcolor = (255,255,255) #生成背景图片 image = Image.new('RGB',
#!/usr/bin/env python #coding:utf-8 import psutil import time import sys from optparse import OptionParser
exif-py是一个纯python实现的获取图片元数据的python库,官方下载地址: http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF
pil功能强大,convert方法可以轻易的将图片转换,下面的代码可以将图片转换成黑白效果 from PIL import Image image_file = Image.open("convert_image.png") # open colour image image_file = image_file.convert('1') # convert image to black and w
''' @author: Administrator ''' #coding=utf-8 import os import shutil dir = "G://tmp//sz//ngtsverify" def removeDir(): for root, dirs, files in os.walk(dir, True, None, False): if 'CVS' in root: print(
python将html表格转换成CSV 使用方法:python html2csv.py *.html 这段代码使用了 HTMLParser 模块 #!/usr/bin/python # -*-