SoFunction
Updated on 2025-03-02

Python gets an instance of another method variable through one method in class

1. During the process of automated interface testing, interface data often occurs. For example, some operations require calling session or token returned after login. The following is a simple method to explain it.

class A():

def a_add_b(self):

a=10

b=20

=a+b

print ()

return 

def c_add_ab(self):

c=30

s=c+

print (s)



t=A()

t.a_add_b()

t.c_add_ab()

After running, the print result is

30

60

The above example of obtaining another method variable through one method in the python class is all the content I share with you. I hope you can give you a reference and I hope you support me more.