Create a python like

Create a class that was running at the time

class Clas:
        print("I love Chian")

Here Insert Picture Description
Nesting a function in the class, and perform this function, class functions are required to carry self parameter and must be the first

class Clas:
    def p(self):
        print("我爱中国")
Clas().p()

Here Insert Picture Description
The print return into an argument and prints

class Clas:
    def p(self):
        return "i love chian"
print(Clas().p())

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/GrofChen/article/details/92398173