碼迷,mamicode.com
首頁 > Windows程序 > 詳細

FileExistsError: [WinError 183] 當文件已存在時,無法創建該文件。

時間:2021-07-26 16:53:37      閱讀:0      評論:0      收藏:0      [點我收藏+]

標簽:文件   pre   錯誤   rgb   path   pat   ror   報錯   file   

源代碼:

train_dir = os.path.join(base_dir, train)
os.mkdir(train_dir)

錯誤提示:

FileExistsError: [WinError 183] 當文件已存在時,無法創建該文件。

修改代碼:

train_dir = os.path.join(base_dir, train)
if not os.path.exists(train_dir):
    os.mkdir(train_dir)

寫上這條語句能夠再次運行代碼,再次運行代碼不再報錯。

FileExistsError: [WinError 183] 當文件已存在時,無法創建該文件。

標簽:文件   pre   錯誤   rgb   path   pat   ror   報錯   file   

原文地址:https://www.cnblogs.com/pistachio0812/p/15059430.html

(0)
(0)
   
舉報
評論 一句話評論(0
登錄后才能評論!
? 2014 mamicode.com 版權所有  聯系我們:gaon5@hotmail.com
迷上了代碼!
4399在线看MV_久久99精品久久久久久久久久_成人又黄又爽又刺激视频_能收黄台的app不收费