我有一个关于在命令行上的虚拟环境中测试的问题。我检查,如果下面的Python代码:如何在命令行上在虚拟环境中的python测试中打印变量的内容
import requests
headers = {"X-Access-Token": "your_api_token"}
url = "https://api.apps.com"
result = requests.get(url, headers=headers)
将给予以下回应:
{
"api_version": "0.0.9",
"store_name": "Test store",
"store_url": "test.myshopify.com"
}
,我在下面的到我的虚拟环境的命令行(也打字测试此,只要注意,我是一个preprod服务器上):
(env) [email protected]:~$ python
import requests
headers = {"X-Access-Token": "abc123"}
url = "https://api.apps.com"
result = requests.get(url, headers=headers)
print result
当我键入print result
,但是,我得到:
<Response [200]>
我在做什么错?
你期望得到什么?响应代码200意味着请求成功。 –
你想'print result.json()'?你似乎关心有效负载,而不仅仅是响应。 – jonrsharpe
要打印html /网页,请尝试'print result.content'。 – xyres