python - Delete Extra Space from Values In List -
i have list of numbers in python space in front. how remove space (so numbers left)? short illustration below (note space):
list = [' 5432', ' 23421', ' 43242', .......]
use str.lstrip
here, white-space @ front:
list = [s.lstrip() s in list] # ['5432', '23421', '43242', ...]
or in case, seeing know how many spaces there can do:
list = [s[1:] s in list]
python string list
No comments:
Post a Comment