带有r'的变量中的路径 [英] Path in Variable with r'
本文介绍了带有r'的变量中的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要替换为: 路径= r'C:/文件夹 有了这个: 路径= r'变量
I want to replace this: path = r'C:/Folder with this: path = r'variable
在其他地方定义了变量的地方.
Where variable is defined elsewhere.
不确定如何将变量名放在r'后面
In not sure how to put the variable name after the r'
推荐答案
只需使用path = variable
.
r'...'
表示法的要点是用于编写原始字符串文字;它更改了引号内字符转义的规则.如果您只是从另一个变量获取值,则不需要r
,因为您无需编写字符串文字.
The point of the r'...'
notation is for writing raw string literals; it changes the rules for character escaping inside of the quotes. If you're just getting the value from another variable, there's no need for an r
since you're not writing a string literal.
这篇关于带有r'的变量中的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文