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.
如何让 de 用户输入二进制数?在我将它保存在一个变量中之后,我如何将这个数字分成两部分?比如:
数字 = 11110000
结果:
数字 1 = 1111 数字 2 = 0000
要将字符串转换为二进制表示,您可以执行以下操作:
number = [bool(int(x)) for x in '11110000'] number1 = number[:4] number2 = number[4:]