当前位置:主页 > 软件编程 > Python代码 >

python判断文件是否存在,不存在就创建一个的实例

时间:2021-06-27 08:22:03 | 栏目:Python代码 | 点击:

如下所示:

try:
  f =open("D:/1.txt",'r')
  f.close()
except IOError:
  f = open("D:/1.txt",'w')

您可能感兴趣的文章:

相关文章