Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 python 新手,想接受这个
K=[['d','o','o','r'], ['s','t','o','p']]
打印:
door, stop
怎么样:
', '.join(''.join(x) for x in K)
使用str.join()和map():
str.join()
map()
In [26]: K=[['d','o','o','r'], ['s','t','o','p']] In [27]: ", ".join(map("".join,K)) Out[27]: 'door, stop'
S.join(iterable) -> 字符串 返回一个字符串,它是可迭代的字符串的串联。元素之间的分隔符是 S。
S.join(iterable) -> 字符串
返回一个字符串,它是可迭代的字符串的串联。元素之间的分隔符是 S。