python使用bin()可以减少编码所需的时间,还可以消除您在上述两种方法中看到的麻烦。
句法 :
斗(A)
参数:
a:转换返回值的整数
:
整数或int对象的二进制字符串。
例外情况:
在参数中发送浮点值时引发TypeError。
# Python code to demonstrate working of
# bin()
# function returning binary string
def Binary(n):
s = bin(n)
# removing "0b" prefix
s1 = s[2:]
return s1
print("The binary representation of 100 (using bin()) is : ",end="")
print(Binary(100))
print("The binary representation of 100 (using bin()) is : ",end="")
print(Binary(100))
输出:
二进制表示100(使用bin())是:1100100
三个资料Q群下载不了也转发不了,先放这里Fine_tuning.zipLangChain.zipdata_clear.rar