Linux下首行一定要加这句话:!/usr/bin/Python,!/usr/bin/Python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器。不加的话会报错,windows下倒不用。
参考文章:http://blog.csdn.net/wh_19910525/article/details/8040494
参考文章:http://blog.csdn.net/wh_19910525/article/details/8040494
2017-06-02
for line in f 就行了,python专门为for关键字做了迭代器的语法糖。在for循环中,Python将自动调用工厂函数iter()获得迭代器,自动调用next()获取元素,还完成了检查StopIteration异常的工作。。。
2017-05-28
help(f.write)
write(...)
write(str) -> None. Write string str to file.
Note that due to buffering, flush() or close() may be needed before
the file on disk reflects the data written.
养成help一下的好习惯
write(...)
write(str) -> None. Write string str to file.
Note that due to buffering, flush() or close() may be needed before
the file on disk reflects the data written.
养成help一下的好习惯
2017-05-07