Python bin() 函數

Python 內置函數 Python 內置函數


描述

bin() 返回一個整數 int 或者長整數 long int 的二進位表示。

語法

以下是 bin() 方法的語法:

bin(x)

參數

  • x -- int 或者 long int 數字

返回值

字串。


實例

以下展示了使用 bin 函數的實例:

>>>bin(10) '0b1010' >>> bin(20) '0b10100'

Python 內置函數 Python 內置函數