dyoo at hkn.eecs.berkeley.edu
Wed Jun 23 22:52:26 CEST 2004
Rigga <Rigga at hasnomail.com> wrote:
: I am having problems when it comes to data in the file that wraps
: over two lines i.e.
: las -
: What i want to be able to do is to some how strip all the spaces from it
: so while it is contained as a variable so it equal 'las - lomas'
Are you stripping as you're reading the file, line by line, or are you
calling strip() at the very end? Without seeing code, it's a little
hard to tell what you're doing.
: I have tried it using the string.strip(myvariable,"") however that
: doesnt appear to do anything.
Ah, ok. string.strip() is deprecated, so you probably shouldn't use
(... And, also, it is being misused. The delimiter -- the second
argument to string.strip() --- has to be nonempty to have any real
Instead, you can just use the strip() method of strings. For example:
>>> msg = " hello world "
'hello world '
' hello world'
for a comprehensive list of the methods that a string can support.
More information about the Python-list