我运行python3.9,我的代码有这个问题:
我要去找TypeError: can't concat str to bytes
这是我的密码
try:
with urllib.request.urlopen(link, headers) as f:
print(f.read().decode('utf-8'))
except urllib.error.URLError as e:
print(e.reason)
对如何解决这个错误有什么想法吗?
发布于 2022-02-09 14:24:26
你在里面有这么多的打字。主要是read
应该是read()
。
try:
with urllib.request.urlopen(link) as response:
data = response.read().decode('utf-8')
print(data)
except Exception as e:
print(e)
https://stackoverflow.com/questions/71050876
复制相似问题