Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 卸下'';和\n在Python的strling列表中_Python 2.7 - Fatal编程技术网

Python 2.7 卸下'';和\n在Python的strling列表中

Python 2.7 卸下'';和\n在Python的strling列表中,python-2.7,Python 2.7,我有一个字符串列表: ['', '', '1.200003317775e-04\n'] 如何删除此字符串中的“”和\n ['1.200003317775e-04'] 谢谢请使用以下列表: In [89]: L = ['', '', '1.200003317775e-04\n'] In [90]: [i.rstrip() for i in L if i!=''] Out[90]: ['1.200003317775e-04'] [item.strip() for item in lst if

我有一个字符串列表:

['', '', '1.200003317775e-04\n']
如何删除此字符串中的“”和\n

['1.200003317775e-04']

谢谢

请使用以下列表:

In [89]: L = ['', '', '1.200003317775e-04\n']

In [90]: [i.rstrip() for i in L if i!='']
Out[90]: ['1.200003317775e-04']
[item.strip() for item in lst if item]
因此:

>>> lst = ['', '', '1.200003317775e-04\n']
>>> [item.strip() for item in lst if item]
['1.200003317775e-04']
>>> 

\n总是出现在末尾,或者它可能在列表中的第一个或中间?