日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:Python教程:int()函數(shù)的用法解析

Python中的函數(shù)有很多,之前我們有講過int()函數(shù),今天就具體用法給大家進行講解。

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供圖們網(wǎng)站建設(shè)、圖們做網(wǎng)站、圖們網(wǎng)站設(shè)計、圖們網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、圖們企業(yè)網(wǎng)站模板建站服務(wù),十年圖們做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

int()是Python的一個內(nèi)部函數(shù) ,Python系統(tǒng)幫助里面是這么說的。

>>> help(int)  
Help on class int in module __builtin__:  
class int(object)  
 | int(x[, base]) -> integer  
 |   
 | Convert a string or number to an integer, if possible. A floating point  
 | argument will be truncated towards zero (this does not include a string  
 | representation of a floating point number!) When converting a string, use  
 | the optional base. It is an error to supply a base when converting a  
 | non-string. If base is zero, the proper base is guessed based on the  
 | string content. If the argument is outside the integer range a  
 | long object will be returned instead.  
>>> int(12.0)  
12


int()函數(shù)可以將一個數(shù)轉(zhuǎn)化為整數(shù)

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


這里有兩個地方要注意:

1)12要以字符串的形式進行輸入,如果是帶參數(shù)base的話

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


>>> int('0xa',16)  
10 
>>> int('10',8)  
8

對int()函數(shù)有遺忘的,可以查詢之前的文章進行知識回顧。更多Python學(xué)習(xí)推薦:PyThon學(xué)習(xí)網(wǎng)教學(xué)中心。

(推薦操作系統(tǒng):windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。)


名稱欄目:創(chuàng)新互聯(lián)Python教程:Python教程:int()函數(shù)的用法解析
當(dāng)前路徑:http://www.dlmjj.cn/article/cdjeieh.html