How to read Windows file in Linux environment?

百般思念 提交于 2019-12-02 01:40:24
dos2unix yourfile.py
python yourfile.py

If you don't have dos2unix, here is some python code you can use instead. Just put this in dos2unix.py, and run python dos2unix.py yourfile.py above:

import sys
filename = sys.argv[1]
text = open(filename, 'rb').read().replace('\r\n', '\n')
open(filename, 'wb').write(text)

This code was copied from Python dos2unix one liner.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!