小编Leo*_*ung的帖子

从requests.exceptions.HTTPError获取HTTP错误代码

我抓住这样的例外,

def get_url_fp(image_url, request_kwargs=None):
    response = requests.get(some_url, **request_kwargs)
    response.raise_for_status()
    return response.raw


try:
   a = "http://example.com"
   fp = get_url_fp(a)

except HTTPError as e:
    # Need to check its an 404, 503, 500, 403 etc.
Run Code Online (Sandbox Code Playgroud)

python exception http python-requests

36
推荐指数
2
解决办法
3万
查看次数

python valueerror:解压缩的值太多了

我是一个蟒蛇初学者.我试图运行此代码:

def main():
    print ( " This program computes the average of two exam scores . ")
    score1,score2 = input ("Enter two scores separated by a comma:")
    average = (score1 + score2)/2.0
    print ("The average of the score is : " , average )
Run Code Online (Sandbox Code Playgroud)

当我召唤时,main()我得到了这个ValueError:

ValueError: too many values to unpack (expected 2)
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?

python python-3.x

6
推荐指数
2
解决办法
6万
查看次数

标签 统计

python ×2

exception ×1

http ×1

python-3.x ×1

python-requests ×1