Reputation: 135
Using Python 3.7, I have a string s defined as
s = '//10.0.0.3/research'
.
I need some operator on s to produce '\\\10.0.0.3\research'
as the output.
I understand about backslashes being escape characters, but I cannot for the life of me figure out what the proper s.replace()
statement would look like to produce what I want (I need the backslashes because that's what the DOS 'net use' command needs to see when assigning UNC paths to drive letters). Ideas?
Upvotes: 1
Views: 5075
Reputation: 1917
don't forget to assign it back to s
:
s = '//10.0.0.3/research'
s = '\\' + s.replace("/", "\\")
print(s)
outputs:
\\10.0.0.3\research
Upvotes: 1