我有以下词典:
mydict = {'mindestens': 2,
'Situation': 3,
'österreichische': 2,
'habe.': 1,
'Über': 1,
}
如何从中获取列表/文本,即当数字在字典中映射到它时,字典中的字符串会重复:
mylist = ['mindestens', 'mindestens', 'Situation', 'Situation', 'Situation',.., 'Über']
mytext = 'mindestens mindestens Situation Situation Situation ... Über'
您可以只使用循环:
^{} 库为此类情况提供了方便的功能:
输出:
对于文本版本-加入列表项很简单:
' '.join(<iterable>)
相关问题 更多 >
编程相关推荐