Using strip() to clean up a string

python, python-3.x, regex, string

Solution

Strings are immutable. `string.strip()` doesn't change `string`, it's a function that returns a value. You need to do:

Temp = Temp.strip()

Note also that calling `strip()` without any parameters causes it to remove all whitespace characters, including `\n`

As stalk said, you can achieve your desired result by calling `strip("',/\n")` on `Temp`.

Problem

I am new to python and I have a string that looks like this `Temp = "', '/1412311.2121\n`" my desired output is just getting the numbers and decimal itself.. so im looking for ``` 1412311.2121 ``` as the output.. trying to get rid of the ', '/\n in the string.. I have tried Temp.strip("\n") and Temp.rstrip("\n") for trying to remove \n but i still seems to remain in my string. :/... Does anyone have any ideas? Thanks for your help.

Original source