python跨平台读写文件(Windows linux)

来源:互联网 发布:网络投资平台有哪些 编辑:程序博客网 时间:2024/06/06 04:46

由于windows、linux换行符的不同,导致在不同平台下生成的文件,经常会出现读写异常


解决方法:

f = open('words.txt', 'rU')
Python's universal newline support