有时候在解析数据出来的时候总是会出现空格,回车\n,制表符\t,或者空,可尝试以下操作:

>>> list1 = ['hello,world!', ' ', '\n', '\t', '', 'I am here.']
>>> [x.strip() for x in list1 if x.strip()!='']
['hello,world!', 'I am here.']
>>>

  

 

相关文章:

  • 2021-11-22
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-01-09
  • 2022-02-19
相关资源
相似解决方案