typeerror' bytes'对象不可调用

时间:2014-12-16 07:46:33

标签: python byte typeerror

我的代码:

import psycopg2
import requests
from urllib.request import urlopen
import urllib.parse
uname = " **** "
pwd = " ***** "
resp = requests.get("https://api.flipkart.net/sellers/skus/SKUID/listings", auth=(uname, pwd))
con_page = resp.content()
print (con_page)

我收到此错误:

Traceback (most recent call last):

File "C:\Users\Prime\Documents\NetBeansProjects\Fp_API\src\fp_api.py", line 18, in <module>

    con_page = resp.content()

TypeError: 'bytes' object is not callable

1 个答案:

答案 0 :(得分:6)

根据documentationrequests.get()的返回值为requests.Response,其content字段的类型为bytes,而不是content() con_page = resp.content 方法。

请改为尝试:

{{1}}