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
相關文章
相關標籤/搜索