Python what is '*' used for
This question already has an answer here:
This is called the "splat" operator. For more information on it, see the Python documentation on it.
What it's basically doing is this:
print(reversed(binary)[0], reversed(binary)[1], ..., sep='')
Essentially, it uses the array elements as arguments instead of passing the array as a single argument itself.
>>> lst = [1, 2, 3]
>>> print(lst) # equivalent to `print([1, 2, 3])'
[1, 2, 3]
>>> print(*lst) # equivalent to `print(1, 2, 3)'
1 2 3
>>> print(reversed(lst))
<list_reverseiterator object at 0x7f4863ae4a20>
>>> print(*reversed(lst))
3 2 1
链接地址: http://www.djcxy.com/p/53548.html
上一篇: 无法理解分配变量的Python语法
下一篇: Python什么是'*'用于