请教关于timer在类中使用的问题

我想编一个不停打印hello的程序。下面这个程序运行后,我能看到程序还在运行中,一直没有停止,却不能打印hello。请问是哪里有问题?谢谢!


import PyQt5.QtCore
import sys

app = PyQt5.QtCore.QCoreApplication(sys.argv)

def test():
    huo = Huo()
    print('test')
    
class Huo:
    def __init__(self):
        self.timer = PyQt5.QtCore.QTimer()
        self.timer.timeout.connect(lambda: print("hello"))
        self.timer.start(500)
        
    def run(self):
        print('Huo')

test()
app.exec_()

你建了一个类,新建对象了吗

参考下:

https://www.5axxw.com/questions/content/lytj10

while True:
print ('hello')
就能一直打印hello