📌  相关文章
📜  写一个文件python代码示例

📅  最后修改于: 2022-03-11 14:46:08.187000             🧑  作者: Mango

代码示例5
# read, write, close a file
# catch error if raise
try:
    file = open("tryCatchFile.txt","w") 
    file.write("Hello World")

    file = open("tryCatchFile.txt", "r")
    print(file.read())
except Exception as e:
    print(e)
finally:
    file.close()