What does & mean in python

前端 未结 5 2555
长情又很酷
长情又很酷 2020-11-28 08:20

Hi I came across the following code

numdigits = len(cardNumber)
oddeven = numdigits & 1

what exactly is going on here? I\'m not sure wh

5条回答
  •  天命终不由人
    2020-11-28 09:01

    In addition, & is also used for taking the intersection of two Python sets:

    set1 = {0,1,2,3}
    set2 = {2,3,4,5}
    print(set1 & set2)
    >>>set([2, 3])
    

提交回复
热议问题