Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获取文本文件并将数据打印为包含所有 /n 和 /r 以及其他代码的原始格式?
谢谢-Hyflex
print(repr(open(filename, 'rb').read()))
with open('filename.txt') as file: contents = file.read() print repr(contents)
您也可以在记事本++ 等编辑器中打开文件,然后单击段落按钮以查看所有换行符和其他隐藏字符。