«

【Python】使用print函数打印文件

azurekiln 发布于 阅读:51 Python程序设计


输出Hello World 到相对路径 file.txt 的文件中

print("Hello World", file=open("file.txt", "w"))

输出Hello World 到绝对路径 D:/file.txt 的文件中

print("Hello World", file=open("D:\\file.txt", "w"))


扫描二维码,在手机上阅读
收藏
请先 登录 再评论