国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python中int()函數(shù)的用法淺析

2020-02-16 10:26:02
字體:
供稿:網(wǎng)友

int()是Python的一個(gè)內(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ù)可以將一個(gè)數(shù)轉(zhuǎn)化為整數(shù) 

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

這里有兩個(gè)地方要注意:1)12要以字符串的形式進(jìn)行輸入,如果是帶參數(shù)base的話

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

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

總結(jié)

以上所述是小編給大家介紹Python中int()函數(shù)的用法淺析,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對武林站長站網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 马龙县| 平邑县| 买车| 临汾市| 普兰店市| 中方县| 开平市| 九龙县| 得荣县| 津市市| 宝兴县| 阿勒泰市| 白水县| 邻水| 谷城县| 石河子市| 沧源| 尖扎县| 健康| 宁乡县| 河间市| 宜宾市| 虎林市| 绥阳县| 柏乡县| 东台市| 沙坪坝区| 宁强县| 若尔盖县| 高雄市| 金堂县| 任丘市| 南岸区| 福泉市| 巨野县| 巴彦县| 涡阳县| 双峰县| 沾化县| 公安县| 重庆市|