随笔分类 -  python

python 一些模块
摘要:os 模块os.listdir(path)显示当前文件夹下的文件 以列表形式返回os.path.isdir(path) 判断当前文件是否是文件夹os.path.join(path, file) 将路径与文件连接 返回一个新的文件路径 阅读全文

posted @ 2014-11-13 17:18 stucs 阅读(161) 评论(0) 推荐(0)

Python基础教程(第四章)
摘要:dict()函数可通过其它映射或者(键,值)这样的序列建立字典 // dict 并不属于函数,它是像list tuple str一样的类型items = [('name', 'gumy'), ('age', 20)]d = dict(items)或者 d = dict(name = 'gumy', ... 阅读全文

posted @ 2014-11-11 10:20 stucs 阅读(204) 评论(0) 推荐(0)

Python基础教程(第五章)
摘要:序列解包多个赋值操作可以同时进行 x, y, z = 1, 2, 3也可以x, y = y, x上述的赋值实际上进行了序列解包——将多个值的序列展开,然后放到变量的序列中。如下所示>>>values = 1, 2, 3>>> values(1, 2, 3)>>>x, y, z = values>>>... 阅读全文

posted @ 2014-09-17 11:08 stucs 阅读(125) 评论(0) 推荐(0)

Python基础教程(第三章)
摘要:字符串格式化: format = "hello %s,%s enough for ya" // format称为格式化字符串 value = ('world', 'hot') print format % value模板字符串:from string import Tem... 阅读全文

posted @ 2014-09-16 09:39 stucs 阅读(169) 评论(0) 推荐(0)