python中将反斜杠''变为正斜杠''

Python011

python中将反斜杠''变为正斜杠'',第1张

Windows文件的路径是按反斜杠 " \ " 分开的 例如:D:\protect\nodejs\test\testmkdir\assets\res\monster Linux文件路径是使用正斜杠 " / " 分开。 例如:/protect/nodejs/test/testmkdir/assets/res/monster/ 反斜杠 " \ " 的路径,linux中无法识别 需要把反斜杠 " \ " ,转为正斜杠" / " python 中字符串的replace方法进行替换,如下所示: #遍历目录文件 for filepath,dirs,filelistin os.walk(upload_path):      for filenamein filelist:           curFile = os.path.join(filepath,filename)#路径的拼接           curFile = curFile.replace('\\','/')#将路径中的反斜杠变为" / "

python中输入代码时进行换行输入,一共分为三步。以下是具体的操作步骤:

工具/原料:小米笔记本Pro15.6、Windows11、python3.7.2

1、输入反斜杠\

当输入执行语句后,在尾端输入【反斜杠\】。

2、换行继续输入

点击回车键后,换行继续输入。

3、点击换行

当输入非执行语句时,点击回车键直接换行。