How you chomp in python

F

Fernando Armenta

How you cut off the ^M at the end of a line? rstrip is not working.



string.rstrip(build_number)



thanks,



-F
 
P

Pete Jereb

Fernando Armenta said:
How you cut off the ^M at the end of a line? rstrip is not working.



string.rstrip(build number)


Do you mean the newline character? If your string variable is named
build_number, then

build_number = build_number.rstrip('/n')

works. Sorry if this isn't what you meant. But the format should be
the same. If you did mean ^M then perhaps a hex or octal
representation?
 
J

JZ

How you cut off the ^M at the end of a line? rstrip is not working.

chomp in Perl change the string in place
rstrip in Python is method, it does NOT change the string in place
'abc'
 
J

JZ

How you cut off the ^M at the end of a line? rstrip is not working.

Strings in Perl are mutable so chomp() change the string in place.
Strings in Python are *not* mutable, so rstrip() does *not* change
the string in place.
'abc'
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top