標籤: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)