Created
August 14, 2018 01:44
-
-
Save luojiyin1987/942d11ad70c741de44ff0056cc579289 to your computer and use it in GitHub Desktop.
如何把 tuple 轉成 dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tlst = [('a1','b1','q1','p1'), | |
| ('a2','b2','q2','p2'), | |
| ('a3','b3','q3','p3')] | |
| names = 'area brand question price'.split() | |
| lst = [{name:value for name, value in zip(names, t)} for t in tlst] | |
| print(lst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment