摘要: 1,变编译时字符串连接,第一种是正常(‘\’),第二种是不成用的。s1="hello world \ !!!" print 's1: ',s1s2="hello world" "!" "!!! " ' I love you' print 's2: ',s2 s1: hello world !!!s2: hello world!!!! I love you2 字符串模板1 from string import Template2 s=Template('I am 阅读全文
posted @ 2013-05-25 10:30 TianMG 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 废话不多说 直接上代码:s=iter('12345')print 's.next(): ', s.next()print 'type(s.next()):' , type(s.next())print 's.next(): ', s.next()print 'type(s):' , type(s)dic ={ 'a':'c','b':'c'}d=iter(dic)print 'dic= ',dicprint 'type(d): 阅读全文
posted @ 2013-05-25 10:25 TianMG 阅读(527) 评论(0) 推荐(0) 编辑
只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2013-05-24 20:46 TianMG 阅读(8) 评论(0) 推荐(0) 编辑
摘要: config.xml<?xml version="1.0" encoding="UTF-8"?> <employees> <employee> <name lang='en'>linux</name> <age>30</age> </employee> <employee> <name>windows</name> <age>20</age> </employee> < 阅读全文
posted @ 2013-05-15 22:37 TianMG 阅读(918) 评论(0) 推荐(0) 编辑
摘要: 参考文章如下:http://blog.donews.com/limodou/archive/2006/09/04/1028747.aspxhttp://www.cnblogs.com/xuxm2007/archive/2010/08/30/1812566.html 阅读全文
posted @ 2013-05-15 15:18 TianMG 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 第一种方法:(其中url,可用ftp、file等协议)>>> import urllib2>>> response = urllib2.urlopen('http://python.org/')>>> print response.read(),response.geturl(),response.getcode()第二种方法:>>> import urllib2>>> req=urllib2.Request("http://python.org")>>&g 阅读全文
posted @ 2013-05-13 19:36 TianMG 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 参考如下资料:1 http://effbot.org/zone/python-with-statement.html2 http://blog.csdn.net/elevenqiao/article/details/67966533 http://blog.csdn.net/largetalk/article/details/6910277 阅读全文
posted @ 2013-05-13 14:28 TianMG 阅读(104) 评论(0) 推荐(0) 编辑
摘要: argv:命令行参数List,第一个元素是程序本身路径,如需获取参数可用argv[1:]*args and * kwargs简单地说:*args去匹配没有指定参数名的参数,即列举出来的参数agr1,arg2,agr3。**kwargs 去匹配指定参数名的参数,形如:arg1="arg1",arg2="arg2",arg3="arg3"关于*args and * kwargs的使用看下面几个例子:>>> def print_everything(*args): for count,thing in enumerate( 阅读全文
posted @ 2013-05-13 14:09 TianMG 阅读(268) 评论(0) 推荐(0) 编辑
摘要: sys模块 系统信息和方法模块,提供了很多实用的变量和方法: argv:命令行参数List,第一个元素是程序本身路径 builtin_module_names:Python解释器导入的模块列表 modules.keys():返回所有已经导入的模块列表 exc_info():获取当前正在处理的异常类 exc_type、exc_value、exc_traceback:当前处理的异常详细信息 executable:Python解释程序路径 exit(n):退出程序,正常退出时exit(0) getwindowsversion():获取Windows的... 阅读全文
posted @ 2013-05-13 14:01 TianMG 阅读(353) 评论(0) 推荐(0) 编辑
摘要: os.sep 可以取代操作系统特定的路径分割符os.linesep 字符串给出当前平台使用的行终止符。例如,Windows使用'\r\n',Linux使用'\n' 而Mac使用'\r'。os.name 字符串指示你正在使用的平台。比如对于Windows,它是'nt',而对于Linux/Unix用户,它是'posix'os.getcwd() 函数得到当前工作目录,os.getenv()和os.putenv() 函数分别用来读取和设置环境变量。os.listdir(dirname):列出dirname下的目录和文件os 阅读全文
posted @ 2013-05-13 12:02 TianMG 阅读(540) 评论(0) 推荐(0) 编辑