1. split分割保留分隔符
import re
a = "how are you"
b = re.split(r"([ ])", a)
print(b)
答:使用re.split(),在需要保留的分隔符外面套一个小括号,即可保留分隔符分割
2. 不移动文件重命名
import os
os.rename(ori_name, new_name)
3. 并排组合列表
a = ["apple", "pear", "orange"]
b = [3, 4, 2]
c = list(zip(a, b)) # c = [("apple", 3), ("pear", 4), ("orange", 2)]