Python(二)Python基礎資料型別 (Elementary Data Type)

來源:互聯網
上載者:User

標籤:python資料類型

變數

變數是記憶體中的一塊地區

變數的命名:由字母、數字、底線組成並且開頭不能時數字

python中地址變數與c語言剛好相反,一條資料包含多個標籤:

>>> a=1
>>> b=1
>>> id(a)
34909288
>>> id(b)
34909288
整型

註:type()可以查看資料類型

>>> num1=123
>>> type(num1)
<type 'int'>
長整型

#強制定義為長整型:num3=999L

>>> num2=9999999999999999999
>>> type(num2)
<type 'long'>

>>> num3=999L
>>> type(num3)
<type 'long'>
浮點型

#1.2e10代表的數值為1.2的10次方;
#12e9代表的數值為12的9次方;

>>> f1=12.0
>>> type(f1)
<type 'float'>
>>> f2=1.2e10
>>> type(f2)
<type 'float'>
複數類型

#python對複數提供內嵌支援,eg: 3.14j, 8.32e-36j

>>> c=3.14j
>>> type(c)
<type 'complex'>
運算子和運算式

算術運算子:+,-,*,**, /, %, //








Python(二)Python基礎資料型別 (Elementary Data Type)

聯繫我們

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