[英]Line endings and reading and writing to text files
I am writing a small script that will need to read and write to text files on Windows and Linux and perhaps Mac even. 我正在编写一个小脚本,需要在Windows和Linux甚至Mac上读写文本文件。 The script will be used by users on all perhaps all of these platforms (Windows for sure) and interchangeably - so a user who wrote to a file
X
on Windows, may read the file on Linux with the script. 用户可能会在所有这些平台(肯定是Windows)上使用该脚本,并且可以互换使用-因此,在Windows上写入文件
X
的用户可以使用该脚本在Linux上读取该文件。
What precautions should I take or how should I implement my code that it is able to handle line endings across various platforms? 我应该采取什么预防措施,或者应该如何实现能够处理各种平台行尾的代码? (reading and writing)
(读写)
Or this is a non-issue and Python handles everything? 还是这不是问题,Python可以处理所有事情?
It's a non-issue, Python is smart like that. 这不是问题,Python很聪明。 It handles line endings across platforms very well.
它很好地处理了跨平台的行尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.