-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.py
More file actions
38 lines (30 loc) · 879 Bytes
/
string.py
File metadata and controls
38 lines (30 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 字符串处理函数
string = 'Python语言程序设计'
print(len(string), str(123456), hex(255), oct(8))
print(ord('A'), chr(65))
print('\n')
print(string.lower())
print(string.upper())
print(string.isupper())
print(string.islower())
print('\n')
print('123456'.isnumeric())
print(' '.isspace())
print(string.startswith('Python'))
print(string.endswith('语言程序设计'))
print(string.startswith('语言程序', 6, -2, ))
print('\n')
print('1,2,3'.split(','))
print('1,2,3'.split(',', 1))
print('11111'.replace('1', '2'))
print('11111'.replace('1', '2', 3))
print('Python语言程序设计'.center(40))
print('Python语言程序设计'.center(40, '-'))
print('\n')
print('111222333'.count('11'))
print('111222333'.count('11', 1))
print('111222333'.count('11', 3, -1))
print('12312312311'.strip('12'))
print('123'.zfill(10))
print('123'.zfill(2))
print('\n')