Possible Duplicate:
python str.strip strange behavior
I have following piece of code:
st = '55000.0'
st = st.strip('.0')
print st
When i execute, it print only 55 but i expect it to print 55000. I thought that the dot in strip causing this as we usually escape it in Regular Expression so i also tried st = st.strip('\.0') but still is giving same results. Any ideas why it is not just striping .0 and why all zeros striped??
int(round(float(st)))- John Riselvatostrip()removes any characters specified in its argument from the beginning and end of a string, and returns a new string without those characters. - wklst = st.removesuffix('.0'). More on this: stackoverflow.com/a/64295844/1465553 - Saurav Sahu