>>> 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 # -*-
# -*- coding: utf-8 -*- import Image,ImageDraw,ImageFont import random import math, string class RandomChar(): """用于随机生成汉字""" @staticmethod def Unicode(): val = random.randint(0x4E00, 0x9FBF) return u
用python写的小程序,可以用这个程序在固定的目录之间来回的拷贝. copy one directory to another directory @author: ''' import os; import
class_config.py #!/usr/bin/env python #coding:utf-8 '''''此处定义邮件的相关参数''' class Mail_conf(): sender = 'fyxichen@126
目前的任务就是从表1复制出相应的数据,填到表2里面。如果手工复制粘贴,共计110x25=2750个数据,简直累哭。 所以使用Python写了一段程序,借助 xlrd模块 (用来读取表1) xlwt模块 (用来生成表2)来完成此项工作。
就是找到硬盘中所有的MP3文件和wma文件,再随机打开其中的一个。 import os,random disk=['D','E','F','G','H'] def search_file(filename,search_path,pathsep=os.pathsep): for path in search_path.split(pathsep): candidate = os.path.join
# -*- coding: utf-8 -*- ''' ''' import os from PIL import Image pic_dir = r"H:\新建文件夹" for filename in os.listdir(path=pic_dir): if filename.startswith("SAM"): pic_path = os.path.join(pic_dir, filename
[Python]代码 # _*_ coding:utf-8 _*_ #xiaohei.python.seo.call.me:) #win+python2.7.x number = "1350571" with
d(manages) print('all have finished!') quit() [Python]代码 运行结果: I am watching movie 捉妖记 now. I am watching