背景:
win8.1, python3.9, office 365, python idle
要求:
创建空文件。
方法:
代码见下面。
其中,打开文件时,
1. test.xls会有提示,大致是格式辨别不到,是否继续。继续后,可以打开。空文档
2. test.xlsx, 提示无法打开
3. 其余文档,均可以打开,空文档。
import os
with open("test.txt","w") as f:
pass
with open("test.docx","w") as f:
pass
with open("test.xlsx","w") as f:
pass
with open("test.pptx","w") as f:
pass
with open("test.xlsx","w") as f:
pass
print(os.listdir())