python基本數據類型及對象方法
string
1.strip
str_test=‘ Larry ‘
v=str_test.strip()
print(v)
v=str_test.lstrip()
print(v)
v=str_test.rstrip()
print(v)
2. index
print(str_test[2])
3.slice
print(str_test[2:5])
4.concat
a=‘123a‘
print(str_test+a)
5.upper lower isupper islower
v=str_test.upper()
print(v)
v=str_test.lower()
print(v)
v=str_test.casefold()
print(v)
v=str_test.islower()
print(v)
v=str_test.isupper()
print(v)
6.startswith endswith
str_test=‘larry‘
v=str_test.startswith(‘la‘)
print(v)
v=str_test.endswith(‘ry‘)
print(v)
7.capitalize
v=str_test.capitalize()
print(v)
8.count
v=str_test.count(‘r‘)
print(v)
8.center expandtabs
v=str_test.center(20,‘*‘)
print(v)
*******larrr********
str_test = ‘larr\tY\tqwe\nsad\tzxc\tlarr‘
v=str_test.expandtabs(20)
print(v)
larr Y qwe
sad zxc larr
list
dict
tuple
python基本數據類型及對象方法