If I have a string lets say ohh
path2 = '"C:\\Users\\bgbesase\\Documents\\Brent\\Code\\Visual Studio'
And I want to add a " at the end of the string how do I do that? Right now I have it like this.
path2 = '"C:\\Users\\bgbesase\\Documents\\Brent\\Code\\Visual Studio'
w = '"'
final = os.path.join(path2, w)
print final
However when it prints it out, this is what is returned:
"C:\Users\bgbesase\Documents\Brent\Code\Visual Studio\"
I don't need the \ I only want the "
Thanks for any help in advance.
How about?
path2 = '"C:\\Users\\bgbesase\\Documents\\Brent\\Code\\Visual Studio' + '"'
Or, as you had it
final = path2 + w
It's also worth mentioning that you can use raw strings (r'stuff') to avoid having to escape backslashes. Ex.
path2 = r'"C:\Users\bgbesase\Documents\Brent\Code\Visual Studio'
just do:
path2 = '"C:\\Users\\bgbesase\\Documents\\Brent\\Code\\Visual Studio' + '"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With