国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 临武县| 邹平县| 高邮市| 化州市| 博湖县| 梨树县| 循化| 公主岭市| 河曲县| 师宗县| 青海省| 祁阳县| 安丘市| 静宁县| 澄江县| 宣恩县| 洪湖市| 淮北市| 崇义县| 大荔县| 阳谷县| 方正县| 大冶市| 商都县| 汉川市| 台中市| 建德市| 昌邑市| 光泽县| 旺苍县| 乐山市| 灵宝市| 镇远县| 九寨沟县| 平湖市| 三原县| 广灵县| 北流市| 巩留县| 桦南县| 江西省|