如何使用line.split(“,”)将每个值与元组列表分开?(python)
code > for line in path_list:
val=line.split(",")
print val
path_list[ (<__main__.wirelessnode instance at 0x19a2170>, <__main__.wirelessnode instance at 0x19a2290>, <__main__.wirelessnode instance at 0x19a04d0>, <__main__.wirelessnode instance at 0x19a1950>, <__main__.wirelessnode instance at 0x19a1320>, <__main__.wirelessnode instance at 0x19a24d0>)]
AttributeError:'tuple'对象没有属性'split'
答案 0 :(得分:1)
path_list
是元组列表。
像list
这样的tuple
已经是&#34;项目序列&#34;。您可以使用for in
:
for line in path:
for val in line:
print val