Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Iteration over strings
- From: stefan.behnel-n05pAM at web.de (Stefan Behnel)
- Subject: Iteration over strings
- Date: Wed, 01 Aug 2007 09:50:58 +0200
> 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. http://docs.python.org/lib/module-os.path.html Especially the normpath() function should be of interest. Stefan
- Prev by Date: split a string of space separated substrings - elegant solution?
- Next by Date: Error with Tkinter and tkMessageBox
- Previous by thread: Iteration over strings
- Next by thread: Wing IDE for Python v. 3.0 beta1 released
- Index(es):