在Python中执行方法/函数时无输出

123*_*php 2 python variables

命令行上没有输出。同样,该变量input也无法设置。

我试着从类中删除变量,结果相同。

class test:
    input = ""

    def __init__(this, input):
        this.input = input

    def output(this):
        print(this.input)

obj = test("hallo")
obj.output
Run Code Online (Sandbox Code Playgroud)

我希望输出是hallo

bru*_*nns 6

您需要调用方法,而不仅仅是引用它:

obj.output()
Run Code Online (Sandbox Code Playgroud)