python 常用高效代码写法集锦

Posted on 2016-03-09 15:17  Vincent90  阅读(445)  评论(0)    收藏  举报

一.打开文件

#使用 with 语句操作文件对象
with open(r'somefileName') as somefile:
    for line in somefile:
        print line
        # ...more code

 

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3