【发布时间】:2017-12-02 18:59:27
【问题描述】:
我有以下代码:
d = {'one' : '11111111', 'two' : '01010101', 'three' : '10101010'}
string = '01010101 11111111 10101010'
text = ''
for key, value in d.items():
if value in string:
text += key
print(text)
输出:一二三
然而,我想要的输出是字符串的顺序,所以:twoonethree。在 python 中使用字典时这可能吗?谢谢!
【问题讨论】:
标签: string python-3.x dictionary