Convert Variable Name to String?

前端 未结 16 1673
生来不讨喜
生来不讨喜 2020-11-28 04:33

I would like to convert a python variable name into the string equivalent as shown. Any ideas how?

var = {}
print ???  # Would like to see \'var\'
something_         


        
16条回答
  •  一个人的身影
    2020-11-28 04:55

    Does Django not do this when generating field names?

    http://docs.djangoproject.com/en/dev//topics/db/models/#verbose-field-names

    Seems reasonable to me.

提交回复
热议问题