Python interface Automation Test 21: Classes and methods

Source: Internet
Author: User

# Classes and methods

Class Count ():

def __init__ (self, AAA, BBB): # Initialization
# Public parameters can be put in
Print ("Init content is executed when instantiated")
SELF.A = AAA
self.b = BBB
# Add Self is a global variable, no self is a local variable

def ABB (self): # method called inside the # class, not called function
return SELF.A + self.b


def ABB (self, A, b): # method inside the # class, not called function
Return SELF.A * self.b

def aee (self, A, b):
# Self is the object itself, instance parameters of the class itself
Self.abb () # Internal call when directly self. method


If __name__== ' __main__ ': # The following code runs only in the current script
Count = count () # The class is instantiated as an object, there are no arguments at this time, and the methods inside the class can be invoked after instantiation
Count.add (1, 3) # Call the Add method of the A object

b = Count (10, 5)
AA = B.abb ()
Print (AA)

Python interface Automation Test 21: Classes and methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.