Size: 539
Comment:
|
← Revision 4 as of 2009-12-25 07:12:33 ⇥
Size: 539
Comment: converted to 1.6 markup
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
[[TableOfContents]] | <<TableOfContents>> |
Line 7: | Line 7: |
[[Include(ZPyUGnav)]] | <<Include(ZPyUGnav)>> |
Contents
一句话将int转化为二进制字符串
>>> bin = lambda n:'0b'+.join({'0':'0','1':'1','2':'10','3':'11','4':'100','5':'101','6':'110','7':'111','8':'1000','9':'1001','a':'1010','b':'1011','c':'1100','d':'1101','e':'1110','f':'1111'}[x] for x in hex(n)[2:].rstrip('L'))
>>> bin(65535)
"11111111111111111'
反馈