Iteration over strings
stefan.behnel-n05pAM at web.de
Wed Aug 1 09:50:58 CEST 2007
> Robert Dailey wrote:
>> I have the following code:
>> str = "C:/somepath/folder/file.txt"
>> for char in str:
>> if char == "\\":
>> char = "/"
>> The above doesn't modify the variable 'str' directly. I'm still pretty new
>> to Python so if someone could explain to me why this isn't working and what
>> I can do to achieve the same effect I would greatly appreciate it.
I assume what you are actually looking for is the os.path module.
Especially the normpath() function should be of interest.
More information about the Python-list