我有以下的元組談到元組成成對串
[ ('StemCells', 16.530000000000001),
('Bcells', 13.59),
('Monocytes', 11.58),
('abTcells', 10.050000000000001),
('Macrophages', 9.6899999999999995),
('gdTCells', 9.4900000000000002),
('StromalCells', 9.3599999999999994),
('DendriticCells', 9.1999999999999993),
('NKCells', 7.8099999999999996),
('Neutrophils', 2.71)]
什麼,我想創建是創建一個字符串,看起來像這樣:
StemCells(16.53), Bcells(13.59), Monocytes(11.58) .... Neutrophils(2.71)
我怎麼能這樣做方便在Python中?
由於'STR。join'不得不將迭代器變成一個列表(因爲它將兩次傳遞給它),但它實際上稍微有點高性能,它將它傳遞給列表理解。這是我使用list comp而不是生成器表達式的狹義情況。 –