python modify path separator

Idea: Use the replace method of the string to modify it.

        str.repalce('old char','new char')。

str=r'E:\doc\Documents\360截图'
sep= '\\'
path = str.replace(sep, r'/')
# 结果是:'E:/doc/Documents/360截图'

Guess you like

Origin blog.csdn.net/weixin_44992737/article/details/127415928