# 如果有帮助,请点个赞,感谢!
# windows下特殊字符无法用来命名: / \ ? * “ < > | (该内容为百度网友提供)
import re
string = '\-\wqewqe,<->,|,“,”,/,/,:,:,:'
name = re.sub(r'[:/\\?*“”<>|]', '_', string)
print(name)
# 运行结果如下:
D:\PYTHON\python.exe D:/python案例/测试文件.py
_-_wqewqe,_-_,_,_,_,_,_,_,_,_
Process finished with exit code 0