WindowsError:[Error 123] When Replace in filename "%3" by ":"
WindowsError:[Error 123] When Replace in filename "%3" by ":"
我是运行这个脚本:
import os
for filename in os.listdir("."):
newname = filename.replace("%3",":")
if newname != filename:
os.rename(filename,newname)
抛出:
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect:
知道为什么会这样吗?
提前致谢
Windows files cannot contain the ':' character:(或任何 \ / : * ? " < > |
,因为它们是保留字符。)
尝试:
import os
for filename in os.listdir("."):
newname = filename.replace("%3","-")
if newname != filename:
os.rename(filename,newname)
我是运行这个脚本:
import os
for filename in os.listdir("."):
newname = filename.replace("%3",":")
if newname != filename:
os.rename(filename,newname)
抛出:
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect:
知道为什么会这样吗?
提前致谢
Windows files cannot contain the ':' character:(或任何 \ / : * ? " < > |
,因为它们是保留字符。)
尝试:
import os
for filename in os.listdir("."):
newname = filename.replace("%3","-")
if newname != filename:
os.rename(filename,newname)