[英]What do the “>>” symbols mean in Python code: map(chr,[x,x>>8,y])
The error code I get in another file that uses it is: 我在使用它的另一个文件中得到的错误代码是:
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)
UPDATE: @merlin2011: This is confusing me. 更新:@ merlin2011:这让我感到困惑。 the code is hs = md5.new(mkeystr+"".join(map(chr,[x,x>>8,y]))).digest() 代码是hs = md5.new(mkeystr +“”。join(map(chr,[x,x >> 8,y])))。digest()
Where the chr has a comma after it. 在chr后面加逗号的地方。 I thought it was a function from doc.python.org: chr(i) 我认为这是来自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().
If so, is [x,x>>8,y] an iterable for map() I just don't recognize yet? 如果是这样,[x,x >> 8,y]是否可用于我还不认识的map()?
Also, I don't want to change any of this code because it is part of the pyahoolib-0.2 auth.py file. 另外,我也不想更改任何代码,因为它是pyahoolib-0.2 auth.py文件的一部分。 But to get it all working I do not know what to do. 但是,要使一切正常,我不知道该怎么办。
It's the Binary Right Shift Operator : 它是二进制右移运算符 :
From Python Wiki : 从Python Wiki :
x >> y
: Returnsx
with the bits shifted to the right byy
places.x >> y
:返回x
,其位向右移y
位。 This is the same as integer-dividing ( \\\\ )x
by2**y
. 这与x
除以2**y
整数相同( \\\\ )。
如果您想知道,该错误消息表示chr
仅接受0
到256
范围内的参数,并且您的map
函数导致使用超出该范围的值调用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.