<address id="zhpbl"></address>
<noframes id="zhpbl">
<address id="zhpbl"><form id="zhpbl"><th id="zhpbl"></th></form></address>

    <em id="zhpbl"></em>

      <address id="zhpbl"><th id="zhpbl"><progress id="zhpbl"></progress></th></address>
      更多精彩內容,歡迎關注:

      視頻號
      視頻號

      抖音
      抖音

      快手
      快手

      微博
      微博

      python內置函數

      文檔

      python內置函數

      python內置函數有:abs、divmod、max、min、pow、round、sum、bool、int、float、complex、str、bytearray、bytes、memoryview、ord、oct、tuple、map等。
      推薦度:
      導讀python內置函數有:abs、divmod、max、min、pow、round、sum、bool、int、float、complex、str、bytearray、bytes、memoryview、ord、oct、tuple、map等。

      python內置函數是什么?一起來看下吧:

      python內置函數有:

      abs:求數值的絕對值

      >>>abs(-2)
      2

      pmod:返回兩個數值的商和余數

      >>>pmod(5,2)
      (2,1)
      >>pmod(5.5,2)
      (2.0,1.5)

      bool:根據傳入的參數的邏輯值創建一個布爾值

      >>>bool()?#未傳入參數
      False
      >>>bool(0)?#數值0、空序列等值為False
      False
      >>>bool(1)
      True

      all:判斷可迭代對象的每個元素是否都為True值

      >>>all([1,2])?#列表中每個元素邏輯值均為True,返回True
      True
      >>>?all(())?#空元組
      True
      >>>?all({})?#空字典
      True

      help:返回對象的幫助信息

      >>>?help(str)?
      Help?on?class?str?in?module?builtins:
      class?str(object)
      |??str(object='')?->?str
      |??str(bytes_or_buffer[,?encoding[,?errors]])?->?str
      |??
      |??Create?a?new?string?object?from?the?given?object.?If?encoding?or
      |??errors?is?specified,?then?the?object?must?expose?a?data?buffer
      |??that?will?be?decoded?using?the?given?encoding?and?error?handler.
      |??Otherwise,?returns?the?result?of?object.__str__()?(if?defined)
      |??or?repr(object).
      |??encoding?defaults?to?sys.getdefaultencoding().
      |??errors?defaults?to?'strict'.
      |??
      |??Methods?defined?here:
      |??
      |??__add__(self,?value,?/)
      ??????????Return?self+value.

      _import_:動態導入模塊

      index?=?__import__('index')
      index.sayHello()

      locals:返回當前作用域內的局部變量和其值組成的字典

      >>>?def?f():
      ????print('before?define?a?')
      ????print(locals())?#作用域內無變量
      ????a?=?1
      ????print('after?define?a')
      ????print(locals())?#作用域內有一個a變量,值為1
      >>>?f>>>?f()
      before?define?a?
      {}?
      after?define?a
      {'a':?1}

      input:讀取用戶輸入值

      >>>?s?=?input('please?input?your?name:')
      please?input?your?name:Ain
      >>>?s
      'Ain'

      open:使用指定的模式和編碼打開文件,返回文件讀寫對象

      #?t為文本讀寫,b為二進制讀寫
      >>>?a?=?open('test.txt','rt')
      >>>?a.read()
      'some?text'
      >>>?a.close()

      eval:執行動態表達式求值

      >>>?eval('1+2+3+4')
      10

      除了上述舉例的函數之外,內置函數按分類還可分為:

      1、數學運算(7個)

      2、類型轉換(24個)

      3、序列操作(8個)

      4、對象操作(7個)

      5、反射操作(8個)

      6、變量操作(2個)

      7、交互操作(2個)

      8、文件操作(1個)

      9、編譯操作(4個)

      10、裝飾器(3個)

      以上就是小編今天的分享,希望可以幫助到大家。

      文檔

      python內置函數

      python內置函數有:abs、divmod、max、min、pow、round、sum、bool、int、float、complex、str、bytearray、bytes、memoryview、ord、oct、tuple、map等。
      推薦度:
      為你推薦
      資訊專欄
      熱門視頻
      相關推薦
      python遞歸函數 python類的繼承 python string函數 python構造函數 python延時函數 debug error怎么解決 python讀取json并解析 python 列表添加 python字典按值的大小排序 python 排序算法 spring boot mysql配置 vue動態綁定style js date加一天 字符轉換成ascii碼 c語言struct用法 java reentrantlock python tkinter教程 js獲取日期 python numpy教程 opencv安裝教程python python判斷字符串相等 python查看已安裝的包 python強制類型轉換 python input函數怎么用 python類型轉換 python split函數用法 python讀取json python組合數據類型 python查看變量類型 python split函數 c++ template用法 老抽和生抽的區別 拉鏈下滑如何解決 防藍光眼鏡怎么辨別 蔥怎么保存 老姜和生姜的區別 新鮮蘑菇怎么保存 豬腳和豬手有什么區別 亞麻籽油是什么油 白茶保存方法和時間
      Top 少妇高潮太爽了在线视频