OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: 'F:\\yolov5_7.0\\yolov5\\..F:\\yolov5_7.0\\datasets\\VOC'
时间: 2023-10-04 15:09:27 浏览: 155
报错OSError: [WinError 123] 文件名、目录名或卷标语法不正确。是因为路径写法不正确导致的。在原路径中,r 'C:\Users\A\Desktop\社保门禁\ date’中的冒号和引号需要删除。修改后的代码如下:
```python
import os
date_list = ["0711", "0712", "0713", "0714", "0715", "0716", "0717", "0718", "0719", "0720",
"0721", "0722", "0723", "0724", "0725", "0726", "0727", "0728", "0729", "0730",
"0731", "0801", "0802", "0803", "0804", "0805", "0806", "0807", "0808", "0809", "0810"]
for date in date_list:
oldpath = r'C:\\Users\\A\\Desktop\\社保门禁\\1_社保名单.xlsx' # 需要复制的表
newpath = r'C:\\Users\\A\\Desktop\\社保门禁\\' + date + '.xlsx' # 需要复制的表
folderpath = r'C:\\Users\\A\\Desktop\\社保门禁\\' + date # 需要复制的表
print(folderpath)
def mkdir(path):
folder = os.path.exists(path)
if not folder:
os.makedirs(path)
print("--- new folder... ---")
print("--- OK ---")
else:
print("--- There is this folder! ---")
mkdir(folderpath) # 创建文件夹。
```
这样修改后的代码就能正确运行了。
阅读全文