Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以是的,我正在尝试想办法在 python 中将小数转换为二进制
怎么样bin:
bin
>>> bin(42) '0b101010'
In [1]: def dec2bin(n): ...: if not n: ...: return '' ...: else: ...: return dec2bin(n/2) + str(n%2) ...: In [2]: dec2bin(11) Out[2]: '1011'