convert dictionary entries into variables - python

后端 未结 6 1365
长发绾君心
长发绾君心 2020-11-28 22:58

Is there a pythonic way to assign the values of a dictionary to its keys, in order to convert the dictionary entries into variables? I tried this out:

>&g         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 23:31

    Use pandas:

    import pandas as pd
    var=pd.Series({'a':1, 'b':2})
    #update both keys and variables
    var.a=3
    print(var.a,var['a'])
    

提交回复
热议问题