日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python中int函数的用法浅析_Python中int()函数的用法浅析

發布時間:2023/12/2 python 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python中int函数的用法浅析_Python中int()函数的用法浅析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

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

>>> 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()函數可以將一個數轉化為整數

>>> int('12',16)

18

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

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

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

10

>>> int('10',8)

8

總結

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

總結

以上是生活随笔為你收集整理的python中int函数的用法浅析_Python中int()函数的用法浅析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。