从没有zip()的两个列表python创建dict?

use*_*520 -1 python dictionary list python-2.7

我正在使用zip()创建一个dict,如何在没有压缩或numpy的情况下完成它?

def listtodict(list1, list2):
    return dict(zip(list1, list2))  

print listtodict([1, 2, 3, 4, 5], ['a', 'b', 'c', 'd', 'e'])
Run Code Online (Sandbox Code Playgroud)

Joh*_*ooy 7

纯娱乐...

def listtodict(list1, list2):
    return dict(max(vars(__builtins__).items())[1](list1, list2))
Run Code Online (Sandbox Code Playgroud)

  • 爱它.花了我一秒钟来解决你为什么使用`max()`,然后我想起了字母表.;) (3认同)