上一页 1 ··· 26 27 28 29 30
摘要: 根据核心编程里的代码,自己改编的socket聊天工具####client####from socket import *HOST='localhost'PORT=21567BUFSIZ=1024ADDR=(HOST,PORT)while True: tcpCliSock=socket(AF_INET,SOCK_STREAM) tcpCliSock.connect(ADDR) data=raw_input('input your words:') if not data: break tcpCliSock.send('%s\r\n' %data) 阅读全文
posted @ 2012-03-08 21:46 小五义 阅读(691) 评论(0) 推荐(0) 编辑
摘要: 利用xlrd,将excel中某列数据中,含有指定字符串的记录取出,并生成用这个字符串命名的txt文件import osimport xlrd,sys # input the excel fileFilename=raw_input('input the file name&path:')if not os.path.isfile(Filename): raise NameError,"%s is not a valid filename"%Filename #open the excel filebk=xlrd.open_workbook(Filen 阅读全文
posted @ 2012-03-08 21:36 小五义 阅读(9830) 评论(0) 推荐(0) 编辑
摘要: 方法一:用encode和decode如: 1 import os.path 2 import xlrd,sys 3 4 Filename='/home/tom/Desktop/1234.xls' 5 if not os.path.isfile(Filename): 6 raise NameError,"%s is not a valid filename"%Filename 7 8 bk=xlrd.open_workbook(Filename) 9 shxrange=range(bk.nsheets)10 print shxrange11 12 for x 阅读全文
posted @ 2012-03-08 21:33 小五义 阅读(3235) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python#coding=utf-8import os,shutil,stringdir = '/home/tt-ava/test' #这里如果是windows系统,请按windows的目录形式写,如c:\\textfor i in os.listdir(dir): newfile = i.replace('.','_') #用_替代.,规则可以自己写。 oldname = dir +'/'+str(i) ne... 阅读全文
posted @ 2012-03-08 21:31 小五义 阅读(2036) 评论(0) 推荐(0) 编辑
摘要: 模块学习步骤一:手册介绍shutil -- High-level file operations 是一种高层次的文件操作工具类似于高级API,而且主要强大之处在于其对文件的复制与删除操作更是比较支持好。相关API介绍copyfile(src, dst)从源src复制到dst中去。当然前提是目标地址是具备可写权限。抛出的异常信息为IOException. 如果当前的dst已存在的话就会被覆盖掉。注意:Special files such as character or block devices and pipes cannot be copied with this function. 不明白 阅读全文
posted @ 2012-03-08 21:11 小五义 阅读(78764) 评论(4) 推荐(5) 编辑
上一页 1 ··· 26 27 28 29 30