2025-09-10:仓库迁移
This commit is contained in:
9
5.文件与IO/14.绕过文件名编码.py
Normal file
9
5.文件与IO/14.绕过文件名编码.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 默认情况下,文件名是根据系统编码来进行编码的
|
||||
print(sys.getdefaultencoding())
|
||||
|
||||
# 如果你想要无视这种编码规则,可以使用字节串来指定文件名
|
||||
with open(b'test.txt', 'w') as f:
|
||||
print(f.read())
|
Reference in New Issue
Block a user