【发布时间】:2020-06-03 11:12:34
【问题描述】:
我有两个 Python 文件。一个调用另一个,我想将变量文档中的值放入不同 Python 文件的不同函数中。
a.py:
class A:
def abc(object):
self.document= 20
b.py:
import a
def xyz():
print(a.document) // I need the value from document but there is an error.
print(a.A.document)// I need the value from document which is 20 but it also gives me the error.
但是,这给了我错误:
no-member: Method
我怎样才能做到这一点?
【问题讨论】:
-
请说明你想做什么。
a没有变量document。类a.A的任何instance 都有这样的属性document。.document是否应该对所有实例都相同?xyz是否应该在a.A的特定实例上工作?
标签: python python-3.x python-2.7 class