标签:help 类型 upper print 字典 abs 鼠标 lex pre
基本数据类型:
数字
字符串
布尔值
列表
元祖
字典
所有对象所具备的功能都保存在相应的类中。
查看对象的类,或对象所具备的功能。
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功能
整型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)
标签:help 类型 upper print 字典 abs 鼠标 lex pre
原文地址:http://www.cnblogs.com/ttrrpp/p/6596636.html