网络编程
位置:首页>> 网络编程>> Python编程>> 在Python 中同一个类两个函数间变量的调用方法

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

作者:wxy_summer  发布时间:2022-07-02 04:53:57 

标签: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 中同一个类两个函数间变量的调用方法

来源:https://blog.csdn.net/wxy_summer/article/details/53118249

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com