0

我在另一个使用它的文件中得到的错误代码是:

Traceback (most recent call last):
  File "C:\Anaconda\lib\site-packages\pyahoolib-0.2-py2.7.egg\yahoo\session.py", line 107, in listener
    t.send_pk(consts.SERVICE_AUTHRESP, auth.hash(t.login_id, t.passwd, p[94]))
  File "C:\Anaconda\lib\site-packages\pyahoolib-0.2-py2.7.egg\yahoo\auth.py", line 73, in hash
    hs = md5.new(mkeystr+"".join(map(chr,[x,x>>8,y]))).digest()
ValueError: chr() arg not in range(256)

更新:@merlin2011:这让我很困惑。代码是 hs = md5.new(mkeystr+"".join(map(chr,[x,x>>8,y]))).digest()

chr 后面有逗号。我认为这是来自 doc.python.org 的函数:chr(i)

Return a string of one character whose ASCII code is the integer i. For example, chr(97) returns the string 'a'. This is the inverse of ord(). The argument must be in the range [0..255], inclusive; ValueError will be raised if i is outside that range. See also unichr(). 

如果是这样, [x,x>>8,y] 是我还不认识的 map() 的可迭代对象吗?

另外,我不想更改任何代码,因为它是 pyahoolib-0.2 auth.py 文件的一部分。但是要让这一切正常工作,我不知道该怎么做。

4

2 回答 2

1

这是二进制右移运算符

来自Python 维基

x >> y:x右移位返回y。这与将整数除以 ( \\ )相同。x2**y

于 2014-04-13T07:40:55.040 回答
0

如果您想知道,错误消息意味着chr只接受 to 范围内的参数0256并且您的map函数导致使用该范围之外的值调用它。

于 2014-04-13T07:42:49.630 回答