【发布时间】:2016-03-10 19:02:04
【问题描述】:
例子:
address= [' ', 'LUT NAME/Register Address', '0', '1', '2', '3', '4', '5', '10', '11', '12', '13', '14', '15', '17', '18', '23', '24', '34', '36', '37', '38']
我希望它转换为:
address=['LUT NAME/Register Address', '0', '1', '2', '3', '4', '5', '10', '11', '12', '13', '14', '15', '17', '18', '23', '24', '34', '36', '37', '38']
或
address=['LUT NAME/Register Address', ' ', ' ', ' ', ' ']
to address = ['LUT NAME/Register Address']
为了提供更多信息,我从 csv 文件生成它以像数组一样处理它并写入文本文件,但我想删除不需要的空白以便我可以做一些数学运算。 我正在使用 windows shell python 3.5 版本。我试过 split , strip , join 。但不起作用,我收到诸如找不到属性之类的错误。
不胜感激,python 新手。
谢谢
【问题讨论】:
-
我能够在一定范围内使用 del 函数来做到这一点。
标签: arrays list csv whitespace