有没有办法在Python中生成dict中的键列表?例如:
>>>someDict = {'One': 1, 'Two': 2, 'Three': 3}
>>>someList = someDict.keys()
>>>print someList
['One', 'Two', 'Three']
Run Code Online (Sandbox Code Playgroud)
试试这个,
>>>someDict = {'One': 1, 'Two': 2, 'Three': 3}
>>>someList = list(someDict.keys())
>>>print(someList)
['One', 'Two', 'Three']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
460 次 |
| 最近记录: |