上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要: C++ 解决文件重复包含 阅读全文
posted @ 2019-10-12 11:41 李道臣 阅读(327) 评论(0) 推荐(0) 编辑
摘要: import re import socket def service_cilent(new_socket): request = new_socket.recv(1024).decode("utf-8") # Python splitlines() 按照行('\r', '\r\n', \n')分隔,返回一个包含各行作为元素的列表,如果参数 keepends 为 False,... 阅读全文
posted @ 2019-08-14 22:07 李道臣 阅读(536) 评论(0) 推荐(0) 编辑
摘要: import urllib.request import gevent from gevent import monkey monkey.patch_all() def downloader(img_name, img_url): req = urllib.request.urlopen(img_url) img_content = req.read() with open(img_name, " 阅读全文
posted @ 2019-08-13 22:21 李道臣 阅读(473) 评论(0) 推荐(0) 编辑
摘要: import gevent import time # 如果需要默认的 time.sleep(0.5) 需要打补丁 from gevent import monkey monkey.patch_all() def f1(n): for i in range(n): print(gevent.getcurrent(), i) # gevent.sleep... 阅读全文
posted @ 2019-08-13 22:19 李道臣 阅读(580) 评论(0) 推荐(0) 编辑
摘要: def create_num(all_num): print("------1------") a, b = 0, 1 current_num = 0 while current_num < all_num: print("------2------") # 如果一个函数中有yield语句,那么这个就不在是函数,而是一个生成器的模板... 阅读全文
posted @ 2019-08-13 22:17 李道臣 阅读(154) 评论(0) 推荐(0) 编辑
摘要: import time from collections import Iterable from collections import Iterator class Classmate(object): def __init__(self): self.names = list() self.current_num = 0 def add(... 阅读全文
posted @ 2019-08-13 22:16 李道臣 阅读(305) 评论(0) 推荐(0) 编辑
摘要: import os suffix_name_list = [".pdb", ".ilk"] def find_file(path): # 遍历文件夹 for i in os.listdir(path): # 获取文件后缀名 suffix_name = os.path.splitext(i)[-1] if suffix_name in suffix_name_list: # 删除文件 os.remo 阅读全文
posted @ 2019-08-11 20:37 李道臣 阅读(613) 评论(0) 推荐(0) 编辑
摘要: import os import multiprocessing def copy_file(q, file_name, old_folder_name, new_folder_name): """ 完成文件的复制 """ old_file = open(old_folder_name + "/" + file_name, "rb") content = old_file.read() old_f 阅读全文
posted @ 2019-08-11 20:35 李道臣 阅读(589) 评论(0) 推荐(0) 编辑
摘要: import multiprocessing import time import os import random g_nums = [11, 22, 33] def test1(): while True: print("子进程PID = %d,父进程PID = %d" % (os.getpid(), os.getppid())) time.sleep(1) def test2(a, b, c 阅读全文
posted @ 2019-08-11 20:31 李道臣 阅读(188) 评论(0) 推荐(0) 编辑
摘要: import threading import time g_nums = [11, 22] g_num = 0 # 创建一个互斥锁,默认是没有上锁的 mutex = threading.Lock() def test1(): for i in range(5): print("test1 %d " % i) time.sleep(1) def test2(): for i in range(5) 阅读全文
posted @ 2019-08-11 20:30 李道臣 阅读(181) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 13 下一页