python zip实例

(Pdb) sample
[['SOCCER', 'O'], ['-', 'O'], ['JAPAN', 'B-LOC'], ['GET', 'O'], ['LUCKY', 'O'], ['WIN', 'O'], ['CHINA', 'B-PER'], ['IN', 'O'], ['SURPRISE', 'O'], ['DEFEAT', 'O']]
(Pdb) list(map(list, zip(*sample)))
(Pdb) sample
[['SOCCER', '-', 'JAPAN', 'GET', 'LUCKY', 'WIN', 'CHINA', 'IN', 'SURPRISE', 'DEFEAT'], ['O', 'O', 'B-LOC', 'O', 'O', 'O', 'B-PER', 'O', 'O', 'O']]
posted @ 2021-12-13 10:07  zae  阅读(40)  评论(0编辑  收藏  举报