python 判断文件是否存在

使用os.path.exists函数

from os.path import exists
if exists('c.txt'):
    with open('c.txt','a') as f:
        f.write('www.h3blog.com') 
        f.close()
else:
    with open('c.txt','a') as f:
        f.write('www.h3blog.com')
        f.close()