List user defined variables, python

后端 未结 5 1536
天涯浪人
天涯浪人 2021-01-06 05:39

I am trying to iterate through the variables set in a python script. I came across the following:

Enumerate or list all variables in a program of [your favorite lang

5条回答
  •  梦谈多话
    2021-01-06 06:13

    The question title leads me to see this. But this is not what I wanted.

    self-answering is below

    [s for s in dir() if not '__' in s]
    

提交回复
热议问题