python的模块__dict__是有序的吗?

时间:2019-06-28 14:27:12

标签: python python-3.6

我在python文件中有一个声明列表。

a = 1
b = 2
c = 3

我从另一个文件导入,并尝试对其进行迭代。

import themodule
for key, value in themodule.__dict__.items():
   if not key.startswith('_'):
       ...

但是,按声明的顺序获取声明至关重要。有什么办法可以保证吗?

0 个答案:

没有答案