Python :去除list”字符串左右两侧的空格

对于一个List,比如:s=[' ES2 '],因为是List数据类型,不能使用'strip'

操作如下:

>>> s=[' ES2 ']
>>> s = tuple(s)
>>> s[0]
' ES2 '
>>> s = str(s[0])
>>> s.strip()
'ES2'

你可能感兴趣的:(编程,开发语言,python)