I am having a very simple problemm I guess. I am trying to open a file in Python pasting windows "copy as path" option
When I paste into Python console I get
"F:\AVALIACAO-PC-08-04\Liberacao-antes-tubo-reto\analise\2014-12-16_15-23-25.mag"
in order to open the file I need to have this
fname='F:\\AVALIACAO-PC-08-04\\Liberacao-antes-tubo-reto\\nnalise\\2014-12-16_15-23-25.mag'
How can I manage to remove "
and add \\
?
I did managed to remove the " with fname.replace but failed with the \\
Basically you can just paste it as a raw string, that is
fname = r"F:\AVALIACAO-PC-08-04\Liberacao-antes-tubo-reto\analise\2014-12-16_15-23-25.mag"
Change '
to "
doesn't really matter as Python accepts both variants.
But if you really want to change "
to '
then you can do
fname = fname.replace('"',"'")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.