string caracters:

L

luca72

i get a string from a web server and i save it in to a file, that i
open the file and i read the string:
the string looks like :
http://lhti.gs/JKBTYD
after the read i use webbrowser open (sting), but i get the error
because at the end of the string are added '%0D%0A', and if i ask for
the len of the sting it include also the"'%0D%0A".
My question is how i can cut the last part of the string if it is
every time different?

Luca
 
A

Alf P. Steinbach

* luca72:
i get a string from a web server and i save it in to a file, that i
open the file and i read the string:
the string looks like :
http://lhti.gs/JKBTYD
after the read i use webbrowser open (sting), but i get the error
because at the end of the string are added '%0D%0A', and if i ask for
the len of the sting it include also the"'%0D%0A".
My question is how i can cut the last part of the string if it is
every time different?

Try rtrim.

Cheers & hth.,

- Alf
 
B

Bruno Desthuilliers

luca72 a écrit :
i get a string from a web server and i save it in to a file, that i
open the file and i read the string:
the string looks like :
http://lhti.gs/JKBTYD
after the read i use webbrowser open (sting), but i get the error
because at the end of the string are added '%0D%0A',

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Can't tell if this comes from the source ("i get a string from a web
server") or if you (unwantingly) add it yourself when writing to or
reading from the file.
and if i ask for
the len of the sting it include also the"'%0D%0A".
My question is how i can cut the last part of the string if it is
every time different?

You'd be better fixing the problem where it happens. FWIW, str.strip()
might help here.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top