![](/img/trans.png)
[英]Is there a way to pass a variable to a class and create a class variable from it in Python?
[英]Pass variable from class to class Python
我试过这个:
class A(object):
def __init__(self, value):
self.value = value
self.hello(msg = self.value)
def hello(self, msg):
while True:
print(msg)
class B(object):
def __init__(self):
self.data = input("Enter: ")
self.run = A(self.data)
我想在class A
class B
输入,但程序已停止,我不知道为什么。 提前致谢
我试过这个:
class A(object):
def __init__(self, value):
self.value = value
self.hello(msg = self.value)
def hello(self, msg):
while True:
print(msg)
class B(object):
def __init__(self):
self.data = input("Enter: ")
self.run = A(self.data)
我想在class A
class B
输入,但程序已停止,我不知道为什么。 提前致谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.