我想在其中做一个代码我现在在 python 中从用户那里获取路径我想将 '\'
替换为 '/'
我用过 re 但它是回溯告诉我我能做什么
import os,re
address = input("Enter Path You of the Folder Which Contains files")
check=re.compile('\\')
if check.match(address):
for char in address:
if char == '\\':
char.replace(char,'/')
print(address)
我使用 os 是因为其他原因
答案 0 :(得分:0)
address.replace('\\','/') 它将适用于字符串中存在的所有 '\\'。