字符串提取字符:不可超过特定范围
训练replace()替换
split()分隔字符串,join()合并
import time
time01 = time.time()
a = ''
for i in range(1000000):
a += 'sxt'
time02 = time.time()
print('耗时:',str(time02-time01))
time03 = time.time()
li = []
for i in range(1000000):
li.append('sxt')
a = ''.join(li)
time04 = time.time()
print('耗时:',str(time04-time03))
字符串添加尽量使用join(),耗时更少
进行逻辑判断与print初始化
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)