Differences between revisions 3 and 4
Revision 3 as of 2009-10-27 02:33:36
Size: 539
Editor: limodou
Comment:
Revision 4 as of 2009-12-25 07:12:33
Size: 539
Editor: localhost
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)>>

一句话将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'


  • 反馈

MiscItems/2009-02-17 (last edited 2009-12-25 07:12:33 by localhost)