import res = "Product desingATK 30Trace back. TheATK 30 is a nice device. "keywords = ['ATK 30', 'PPK 50', 'HJF12 10']pattern = fr'\s*({"|".join(sorted(map(re.escape, keywords),key=len,reverse=True))})\s*'print(pattern) # => \s*(HJF12\ 10|ATK\ 30|PPK\ 50)\s*print(re.sub(pattern, r' \1 ', s)) # => Product desing ATK 30 Trace back. The ATK 30 is a nice device.
1 回答
蛊毒传说
TA贡献1895条经验 获得超3个赞
初始化后修复网格小框架的小问题
from tkinter import *
root = Tk()
root.geometry('700x500')
# Big Frame
big_frame = LabelFrame(root, text='Big Frame', width=350, height=450, padx=5, pady=5)
big_frame.grid(row=0, column=0, padx=(1, 0), sticky='nsew') # the sticky prevents the label from being inside the frame
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)
# Small Frame
small_frame = LabelFrame(big_frame, text='Small Frame', width=120, height=200)
small_frame.grid(row=0, column=0)
label = Label(small_frame, text='Label')
label.grid(row=0, sticky='nw')
mainloop()
添加回答
举报
0/150
提交
取消