摘要:
``` import re s = "文本 1文本 2" pat1 = re.compile(r"(.*?)") # 非贪婪模式 print(pat1.findall(s)) pat2 = re.compile(r"(.*)") # 贪婪模式 print(pat2.findall(s)) ''' ['文本 1', '文本 2'] ['文本 1文本 2'] ''' ``` 阅读全文
摘要:
``` # 线程隔离 from werkzeug.local import LocalStack import threading # 首先实例化 my_stack = LocalStack() my_stack.push(1) # 主线程入栈 def worker(): print("in worker thread the value is:", my_stack.top) my_stack. 阅读全文
摘要:
38. 用Python实现一个二分查找的函数 42. 写一个快速排序 python def quick_sort(arr): n = len(arr) if n 阅读全文