[英]How to change list of list to a string
I need to get :我需要得到:
'W1NaCl U1NaCl V1NaCl'
from :来自:
[['W1NaCl'], ['U1NaCl'], ['V1NaCl']]
How to get required output in pythonic
way如何以
pythonic
方式获得所需的output
You can do:你可以做:
[[i] for i in 'W1NaCl U1NaCl V1NaCl'.split()]
Split will chop it into words, and the list comprehension will make the inner-arrays拆分会将其切成单词,列表理解将使内部数组
items = [['W1NaCl'], ['U1NaCl'], ['V1NaCl']]
res = " ".join([item[0] for item in items])
Which yields: W1NaCl U1NaCl V1NaCl
产生:
W1NaCl U1NaCl V1NaCl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.