typeerror'bytes'对象不可调用

Man*_*pta 3 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)
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

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
Run Code Online (Sandbox Code Playgroud)

mer*_*011 6

根据文档,返回值为requests.get()a requests.Response,其中包含content类型的字段bytes,而不是content()方法.

试试这个:

con_page = resp.content
Run Code Online (Sandbox Code Playgroud)