[英]How to change list of list to a string
我需要得到:
'W1NaCl U1NaCl V1NaCl'
來自:
[['W1NaCl'], ['U1NaCl'], ['V1NaCl']]
如何以pythonic
方式獲得所需的output
你可以做:
[[i] for i in 'W1NaCl U1NaCl V1NaCl'.split()]
拆分會將其切成單詞,列表理解將使內部數組
items = [['W1NaCl'], ['U1NaCl'], ['V1NaCl']]
res = " ".join([item[0] for item in items])
產生: W1NaCl U1NaCl V1NaCl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.