摘要:
In [7]: a= [1,2] #定义一个list In [8]: a+[3,4] # 使用+操作 Out[8]: [1, 2, 3, 4] In [9]: a Out[9]: [1, 2] In [10]: a.extend([3,4]) # 使用extend操作,其实是在修改a In [11] 阅读全文
摘要:
with open('data.txt', 'r') as f: lines = f.readlines() for line in lines: print(line.split()) 类上面这段代码在python中很常见,就是使用with去管理资源。 其原理就是使用__entry__ 和__ex 阅读全文
摘要:
使用with方式创建线程池,任务执行完毕之后,会自动关闭资源 , 否则就需要手动关闭线程池资源 import threading, time from concurrent.futures import ThreadPoolExecutor, as_completed class MyTask(th 阅读全文
摘要:
首先需要明确一点,正则默认就是贪婪模式,何为贪婪模式? 就是在满足条件的前提下,尽可能多的进行匹配。 下面先来个例子 s ='my tel number is 132-4567-1258' r = re.match(r'(.+)(\d+-\d+-\d+)',s) print(r.groups()) 阅读全文
摘要:
1.测试代码 public class ThreadLocalTest { public static void main(String[] args) { ThreadLocal<String> threadLocal = new ThreadLocal<>(); threadLocal.set( 阅读全文