bul*_*uly 3 python indexing formatting tuples list
我有这个清单:
scores = [
('WillyCaballero', '2'),
('Angeleri', '2'),
('Antunes', '2'),
('FlavioFerreira', '2'),
('Camacho', '2'),
('SamuGarc\xc3\xada', '2'),
('I\xc3\xb1igoMart\xc3\xadnez', '2'),
('Jos\xc3\xa9\xc3\x81ngel', '6')
...
]
Run Code Online (Sandbox Code Playgroud)
如何在一个str变量和输出中存储这样的格式?:
Willy Caballero 2
Angeleri 2
Antunes 2
...
Run Code Online (Sandbox Code Playgroud)
使用str.join,whitespace首先连接元素然后用'\n'
In [25]: print '\n'.join(' '.join(s) for s in scores)
Willy Caballero 2
Angeleri 2
Antunes 2
Flavio Ferreira 2
...
Run Code Online (Sandbox Code Playgroud)