Python 请求在执行前等待按键输入

Python requests waits for key input before executing

我正在学习 python。目前正在编写一些测试应用程序,需要从其他站点获取一些 html 并将其显示在我的浏览器中。为此,我使用:

每次我 运行 应用程序并刷新页面时,我都需要转到终端并按回车键才能继续。我该如何阻止它?我希望它自动执行。

没有特殊的例子或有问题的特殊代码。 运行 标准 requests.get(有些URL)。然后我在我的终端(我曾经启动 virtualenv 和 flask 应用程序)中看到有问题的 URL 并且只有在我在终端中按下回车后才会继续执行。

from flask import Flask
import requests

@route("/")
def test():
    return start_req()

def start_req():
    r = requests.get('https://example.com')
    #now it waits me to hit enter in terminal
    return r.text

好吧,因为我是菜鸟,所以我不知道我的 .py 文件应该以 enter 结尾。我相信这解决了问题。