问题
I want to replace this: path = r'C:/Folder with this: path = r'variable
Where variable is defined elsewhere.
In not sure how to put the variable name after the r'
回答1:
Just use path = variable.
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.
回答2:
This should work:
path = r'%s' % variable
来源:https://stackoverflow.com/questions/28313886/path-in-variable-with-r