当前位置:主页 > 软件编程 > Python代码 >

在Python 中同一个类两个函数间变量的调用方法

时间:2021-02-05 09:31:29 | 栏目:Python代码 | 点击:

如下所示:

class A():
  def test_a(self):
    self.m ="hello"

  def test_b(self):
    self.test_a()
    n=self.m + "world"
    print(n)
if __name__ == '__main__':
  A().test_b()

运行结果:

Python 同一个类两个函数间变量的调用

您可能感兴趣的文章:

相关文章