python如何在脚本中包含列表文件

use*_*318 0 python

我有一个由以下生成的文件:

摘抄:

group0 = ['ParentPom']

group1 = ['Commons','http', 'availability','ingestPom','abcCommons','solrIndex','123Service']

...

group10=['totalCommons','Generator']
Run Code Online (Sandbox Code Playgroud)

我如何在我的python脚本中包含它,尝试导入但没有运气

>>> import dependencies_custom
>>> print (group2[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'group2' is not defined
Run Code Online (Sandbox Code Playgroud)

小智 5

import您正在使用的表单中,您应该能够访问这些组

dependencies_custom.group2[0]
Run Code Online (Sandbox Code Playgroud)

类型表示法.如果您只想使用group2[0]符号,请尝试使用:

from dependencies_custom import *
Run Code Online (Sandbox Code Playgroud)