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中新增函数,使用时要注意版本问题。

posted @ 2017-04-14 14:46  小明子  阅读(1519)  评论(0编辑  收藏  举报