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