Python學習3

來源:互聯網
上載者:User

標籤:file   blog   pos   body   func   def   rom   fun   預設   

到函數了,繼續堅持。

max(,...,)

資料類型轉換

int(‘123‘)

定義函數

def func_name(ele,....,...):

  ...

  return ...

from filename import my_abs(我的函數)來匯入my_abs()函數,注意filename是檔案名稱(不含.py副檔名)

空函數

def nop():

  pass

資料類型檢查可以用內建函數isinstance()實現

預設參數

一是必選參數在前,預設參數在後,否則Python的解譯器會報錯(思考一下為什麼預設參數不能放在必選參數前面);

二是如何設定預設參數。def pow(x,n=2):

Python學習3

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.