python知识:bin函数

bin(x):

英文说明:Convert an integer number to a binary string. The result is a valid Python expression. If x is not a Python int object, it has to define an __index__() method that returns an integer.

New in version 2.6.

中文说明:将整数x转换为二进制字符串,如果x不为Python中int类型,x必须包含方法__index__()并且返回值为integer;

参数x:整数或者包含__index__()方法切返回值为integer的类型;

版本:bin函数是python2.6中新增函数,使用时要注意版本问题。

原文地址:https://www.cnblogs.com/ming-zi/p/6708852.html