Python的資料類型

來源:互聯網
上載者:User

標籤:pytho   常用   mon   and   資訊   作用   money   abc   集合   

1.學習目錄:  數字(整型、長整型,浮點型,複數)  字串  列表  元祖  字典  集合2.學習目標:  1.用途  2.定義方式  3.常用操作 and 內建的方法

  

一.  整形與浮點型  整形 int : money = 6000  age = 22  浮點 float: money = 5.2

  長整型(python3沒有):
  >>> num = 2L
>>> type(num)
>>> <type ‘long‘

  複數:
  >>> num = 1 - 2j  
二. 字串     作用:描述、性別,地址等資訊     定義:定義在單引號 or 雙引號  or 三引號內     name = "tom"     1.優先掌握的操作:        1.按索引值取值(正向取OR反向取)        2.切片        3.長度  len        4.成員運算 與 not in        5.移除空白字元 strip        6.切分split        7.迴圈     2.次要優先掌握:        1.strip, lstrip, rstrip        2.lower, upper        3.startswith,endswith        4.format 三種寫法        5.split, rsplit        6.join        7.replace        8.isdigit#strip     name = "*abc**"     name.strip("*")       name.lstrip("*")      name.rstrip("*")

 

Python的資料類型

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.