简体   繁体   English

“ >>”符号在Python代码中的含义是:map(chr,[x,x >> 8,y])

[英]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 : Returns x with the bits shifted to the right by y places. x >> y :返回x ,其位向右移y位。 This is the same as integer-dividing ( \\\\ ) x by 2**y . 这与x除以2**y整数相同( \\\\ )。

如果您想知道,该错误消息表示chr仅接受0256范围内的参数,并且您的map函数导致使用超出该范围的值调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 x = y 在python中是什么意思? - What does x = y mean in python? Python中x [x <2] = 0的含义是什么? - What does x[x < 2] = 0 mean in Python? 在python 2.7中,“ x!= y”和“ not x == y”有什么区别? - In python 2.7 what's the difference between “x != y” and “not x == y”? 为什么python 2和3中chr(0x24)+ chr(0x84)的结果不同 - Why is the result of chr(0x24) + chr(0x84) different in python 2 and 3 python方法调用末尾的[&#39;x&#39;] [&#39;y&#39;]表示什么? [&#39;x&#39;] [&#39;y&#39;]在函数调用的末尾提到 - What does ['x'] ['y'] at the end of python method call indicate? ['x'] ['y'] is mentioned at the end of function call 这是什么意思:key=lambda x: x[1] ? - What does this mean: key=lambda x: x[1] ? “x 在全局声明之前使用”是什么意思? 蟒蛇2 - What does “x is used prior to global declaration” mean? python 2 如果x&gt; y在x大于y的地方不起作用python 2.7 - if x > y not working where x is greater than y python 2.7 识别python x,y数组中的x,y坐标对 - identify x,y coordinate pair in a python x,y array 在Python(2.7.3)中,如果str(x)中的任何字符都在str(y)中(或str(y)在str(x)中),如何编写一个能够回答的函数? - In Python (2.7.3) how do I write a function that answers if any characters in str(x) are in str(y) (or str(y) are in str(x))?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM