在python中,如何打印列表内部元组

分享于 

1分钟阅读

互联网

  繁體

nvts = {"high": [], "medium": [], "low": [], "log": []}

for a, *b in nvts:print(a, ' '.join(map(str, b)))

h i g hm e di u m ...



nvts = {"high": [], 


 "medium": ["value1"], 


 "low": ["value 2","value 3"], 


 "log": ["more value", "even more value"]}



print("n".join([item for sublist in nvts.values() for item in sublist]))



输出:


value1


value 2


value 3


more value


even more value



如果只想打印key:


print("n".join(nvts.keys()))



输出


high


medium


low


log





lis  列表  print  lists  tup  tuple  
相关文章