在Python中
a = [['z', 'G', 'j', 'E', 'U'], ['%', '#', '(', '!', ')'], ['6', '4', '8', '1', '3']]
我想将上面的嵌套列表打印到并排的字符中 示例输出:
zGjEU%#(!)64813
如何做到这一点?
最佳答案
考虑 nested comprehension以及 str.<b>join</b>
:
>>> a = [['z', 'G', 'j', 'E', 'U'], ['%', '#', '(', '!', ')'], ['6', '4', '8', '1', '3']]
>>> print(''.join(c for chars in a for c in chars))
zGjEU%#(!)64813
关于python - 如何在Python中并排打印嵌套列表到宪章中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74758456/