摘要: os.sep 可以取代操作系统特定的路径分隔符。windows下为 '\\' os.name 字符串指示你正在使用的平台。比如对于Windows,它是'nt',而对于Linux/Unix用户,它是 'posix' os.getcwd() 函数得到当前工作目录,即当前Python脚本工作的目录路径 o 阅读全文
posted @ 2016-03-29 18:28 Jarning_Gau 阅读(718) 评论(0) 推荐(0) 编辑
摘要: import shutil with open('/path/to/file', 'r') as f: with open('/path/to/file.new', 'w') as g: for line in f.readlines(): if '/local/server' not in line: ... 阅读全文
posted @ 2016-03-29 16:26 Jarning_Gau 阅读(1412) 评论(0) 推荐(0) 编辑
摘要: 字符串的split用法说明:Python中没有字符类型的说法,只有字符串,这里所说的字符就是只包含一个字符的字符串!!!这里这样写的原因只是为了方便理解,仅此而已。 由于敢接触Python,所以不保证以后还有没有其他用法,所以会在后面不断加入。。。 1.按某一个字符分割,如‘.’ 1 2 3 4 s 阅读全文
posted @ 2016-03-29 16:20 Jarning_Gau 阅读(412) 评论(0) 推荐(0) 编辑
摘要: from itertools import islice input_file = open(file_name) for line in islice(input_file, 1, None): do_readline() 原文地址:http://blog.csdn.net/vernice/art 阅读全文
posted @ 2016-03-29 15:38 Jarning_Gau 阅读(851) 评论(0) 推荐(0) 编辑