python os.path.exists判断文件或文件夹是否存在

import os #判断文件夹是否存在 dir = os.path.exists('C:\\Users\\Desktop') print('dir:', dir) #判断文件是否存在 file = os.path.exists('C:\\Users\\Desktop\\雍正王朝.txt') print('file:', file) 运行结果python 显示该文件及文件夹都存在code
相关文章
相关标签/搜索