I want to remove [\'
from start and \']
characters from the end of a string.
This is my text:
\"[\'45453656565\']\"
You need to strip your text by passing the unwanted characters to str.strip()
method:
>>> s = "['45453656565']"
>>>
>>> s.strip("[']")
'45453656565'
Or if you want to convert it to integer you can simply pass the striped result to int
function:
>>> try:
... val = int(s.strip("[']"))
... except ValueError:
... print("Invalid string")
...
>>> val
45453656565