📜  尝试打开文件 - Python 代码示例

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

代码示例1
try:
    with open("file.txt","r") as f:
        #stuff goes here
except IOError:
    #do what you want if there is an error with the file opening