9 lines
298 B
Python
9 lines
298 B
Python
import sys
|
|
|
|
if __name__ == "__main__":
|
|
# 默认情况下,文件名是根据系统编码来进行编码的
|
|
print(sys.getdefaultencoding())
|
|
|
|
# 如果你想要无视这种编码规则,可以使用字节串来指定文件名
|
|
with open(b'test.txt', 'w') as f:
|
|
print(f.read()) |