How can I find the index of a back slash within a string? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How can I find the index of a back slash within a string?

f = open("newFile.txt", "w+") pathName = os.path.abspath(f.name) index = pathName.find(r"\") <-- This needs fixing

30th May 2020, 7:09 PM
Jeremy Cruz
Jeremy Cruz - avatar
1 Respuesta
+ 7
You should use a double backslash, that's all. ...find("\\") just make sure it is the right slash, as you will encounter the regular one in Linux and in Sololearn most likely.
30th May 2020, 7:13 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar