python基礎資料型別 (Elementary Data Type)

來源:互聯網
上載者:User

標籤:help   類型   upper   print   字典   abs   滑鼠   lex   pre   

基礎資料型別 (Elementary Data Type):

數字

字串

布爾值

列表

元祖

字典

所有對象所具備的功能都儲存在相應的類中。

 

查看對象的類,或對象所具備的功能。

1、通過type()查看

temp = "alex"
t = type(temp)

 

2、整體查看dir()快速列舉

temp = "alex"
t = type(temp)
print(dir(t))

 

3、查看某類型的功能

temp = "alex"
t = type(temp)
help(type(t))

4、滑鼠點擊

temp = "alex"

temp.upper()

滑鼠放在upper()上,Ctr+左鍵,自動定位到upper功能

 

 

基礎資料型別 (Elementary Data Type)的常用功能:

整型int

n1 = 123
n2 = 456
print(n1+n2) #實際是調用了n1的方法
print(n1.__add__(n2))

 

a1 = "alex"
ret = a1.capitalize()
print(ret)


a1 = "alex"
ret = a1.center(20,‘*‘)
print(ret)

a1 = "alex is alph"
ret = a1.count("a")
print(ret)

a1 = "alex is alph"
ret = a1.count("al",0,10)
print(ret)

temp = "hello"
print(temp.endswith(‘e‘,0,2))


content = "hello\t999"
print(content)
print(content.expandtabs())
print(content.expandtabs(20))

 
s = "alex hello"
print(s.find("ex"))

s = "hello {0}, age{1}"
print(s)
new1 = s.format(‘alex‘,19)
print(new1)


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.