當前位置:首頁 » 編程語言 » pythonbuiltin

pythonbuiltin

發布時間: 2025-01-02 02:57:17

『壹』 python 中的int函數怎麼用

int()是Python的一個內部函數

Python系統幫助裡面是這么說的

[python] view plain

  • >>>help(int)

  • Helponclassintinmole__builtin__:

  • classint(object)

  • |int(x[,base])->integer

  • |

  • |,ifpossible.Afloatingpoint

  • |(thisdoesnotincludeastring

  • |!)Whenconvertingastring,use

  • |theoptionalbase.

  • |non-string.Ifbaseiszero,

  • |stringcontent.

  • |.

  • [python] view plain

  • >>>int(12.0)

  • 12

  • int()函數可以將一個數轉化為整數

    [python] view plain

  • >>>int('12',16)

  • 18

  • 這里有兩個地方要注意:1)12要以字元串的形式進行輸入,如果是帶參數base的話

    2)這里並不是將12轉換為16進制的數,而是說12就是一個16進制的數,int()函數將其用十進制數表示,如下

    [python] view plain

  • >>>int('0xa',16)

  • 10

  • >>>int('10',8)

  • 8

熱點內容
埋點系統存儲方案 發布:2025-03-11 02:41:20 瀏覽:441
編程要很久 發布:2025-03-11 02:41:10 瀏覽:194
筆記本電腦播放mp4時提醒伺服器運行失敗 發布:2025-03-11 02:40:32 瀏覽:439
吉利星瑞尊貴版配置有哪些 發布:2025-03-11 02:34:33 瀏覽:888
ecs中怎麼配置slb 發布:2025-03-11 02:33:17 瀏覽:718
vb圖片保存到資料庫 發布:2025-03-11 02:31:05 瀏覽:841
元件符號編譯器 發布:2025-03-11 02:30:12 瀏覽:72
位交換演算法 發布:2025-03-11 01:57:41 瀏覽:342
網游跟上傳 發布:2025-03-11 01:46:07 瀏覽:62
ro手游腳本模擬器 發布:2025-03-11 01:43:04 瀏覽:890