当我 运行 我的 python 文件正常功能不做任何事情发生,没有任何输出,我如何显示该功能

When I run my python file the normal function doesn't do anything happens, nothing is outputted, how can I display the function

我正在编写一个应该获得用户响应的函数,但是当我 运行 文件没有任何反应,它只是一个空白屏幕,我该如何解决?我尝试在 Whosebug 中搜索,但找不到我要找的东西,提前致谢:)

def get_user_response():
  while True:
    try:
      print ('Enter the number of clickbait headlines to generate: (0 to exit)')
      user = int(input('> '))
      print ('HEADLINES')
      if user == 0:
        for x in range (0,4):
          l = "Exiting Program" + "." * x
          print (l, end="\r")
          sleep(1)
        break
      else:
        print ('a')
    except:
      print ('Invalid - Enter an integer')
def get_user_response(trueorfalse):
     while trueorfalse:
           .....your codes
get_user_response(True)

你的函数应该有这样的参数

您定义了一个函数,但从未在任何地方调用它。这就是为什么该程序首先不是 运行 的原因。随便写

get_user_response()

函数之外的任何地方。

还可以考虑仅将用户输入行包装到 try except 语句中,否则您将捕获函数中可能发生的所有可能错误,而不会收到错误消息。