发送email 带附件的Python代码 代码段

msg['from'] = mail_user msg['subject'] = 'this is a python test mail' try: s = smtplib.SMTP() s.connect(mail_host)

pythopen 2015-01-22   3104   0
Python  

检查网站可用性的Python代码 代码段

#!/usr/bin/env python # coding=utf-8 import socket s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

m2yy 2015-02-01   1745   0
Python  

12306 火车票监控Python代码 代码段

#登陆邮箱 pwd = ''#邮箱密码 to = [''] #发送的邮箱 with open('D:\\Python源码\\city.txt','r') as f: a = f.read() station =

pe6y 2015-03-17   11373   0
Python  

Python3.4图片转换素描 代码段

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

pe6y 2015-03-17   1481   0
Python  

python循环监控远程端口的代码 代码段

txt中每行一个ip地址和端口号,代码可循环监控这些ip地址的指定端口是否正常 #!/usr/bin/env python # -*- coding: gbk -*- import socket,time while

n6xb 2015-04-04   1702   0
Python  

python检测远程udp端口是否打开 代码段

python检测远程udp端口是否打开 import socket import threading import time import struct import Queue queue = Queue

xg48 2015-04-12   3474   0
Python  

python判断远程端口是否打开 代码段

python判断远程端口是否打开,下面的代码判断指定网站的80端口是否打开 import socket sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

xg48 2015-04-12   3106   0
Python  

一个简单的python读写文件脚本 代码段

#!/usr/bin/env python 'makeFile.py -- create a file' import os ls = os.linesep # get filename while True:

jopen 2015-04-17   7203   0
Python  

python 判断文件、文件夹是否存在 代码段

>>> 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 >

jopen 2015-05-06   3788   0
Python  

python获取PC机器名和IP地址 代码段

利用socket包中的gethostname函数获取机器名之后,再调用gethostbyname函数获取机器的IP地址。 import socket def print_machine_info(): host_name = socket.gethostname() ip_address = socket.gethostbyname(host_name) print "Host name: %s"

y3c5 2015-05-11   1086   0
Python  

python获取图片元数据的代码 代码段

exif-py是一个纯python实现的获取图片元数据的python库,官方下载地址: http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF

e2ex 2015-05-14   2096   0
Python  

python通过Tkinter显示网络图片 代码段

Tkinter, PIL and data_stream tested with Python27 and Python33 by vegaseat 01mar2013 ''' import io # allows

mn6e 2015-05-24   1565   0
Python  

python通过wxPython打开并播放wav文件 代码段

wx.Sound(fileName, isResource=False) tested with Python27 and wxPython291 by vegaseat 25jul2013 ''' import

mn6e 2015-05-24   5886   0
Python  

python从ftp服务器下载文件 代码段

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

mn6e 2015-05-24   1254   0
Python  

python通过pil生成图片验证码 代码段

# -*- coding: utf-8 -*- #导入三个模块 import Image,ImageDraw,ImageFont import random import math '''基本功能''' #图片宽度 width = 100 #图片高度 height = 40 #背景颜色 bgcolor = (255,255,255) #生成背景图片 image = Image.new('RGB',

byyc 2015-05-27   1124   0
Python  

python中系统信息获取psutil使用 代码段

#!/usr/bin/env python #coding:utf-8 import psutil import time import sys from optparse import OptionParser

jopen 2015-06-02   882   0
Python  

python用来获得图片exif信息的库代码 代码段

exif-py是一个纯python实现的获取图片元数据的python库,官方下载地址: http://exif-py.svn.sourceforge.net/viewvc/exif-py/source/EXIF

pycct 2015-06-09   4328   0
Python  

python通过pil将图片转换成黑白效果 代码段

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

pycct 2015-06-09   1671   0
Python  

python递归删除指定目录 代码段

''' @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(

mxw8 2015-06-18   979   0
Python  

python将html表格转换成CSV 代码段

python将html表格转换成CSV 使用方法:python html2csv.py *.html 这段代码使用了 HTMLParser 模块 #!/usr/bin/python # -*-

mxw8 2015-06-20   3642   0
Python  
1 2 3 4 5 6 7 8 9 10

关键词

Python