多线程

import threading, time, requests


# class ThreadDemo(threading.Thread):
#
# def run(self):
# time.sleep(1)
# now = time.strftime('%Y-%m-%d %H:%M:%S')
# print(self.name + ":" + now)
#
#
# if __name__ == '__main__':
# for i in range(10):
# de = ThreadDemo()
# de.start()
##########################################################
# def print_one(x, y):
# for i in range(5):
# time.sleep(1)
# now = time.strftime('%Y-%m-%d %H:%M:%S')
# print(threading.current_thread().name + ":" + now)
#
#
# def print_two():
# time.sleep(1)
# now = time.strftime('%Y-%m-%d %H:%M:%S')
# print(threading.current_thread().name + ":" + now)
#
#
# thread_list = []
# for i in range(10):
# # t = threading.Thread(target=print_one, args=(100, 200)).start()
# t = threading.Thread(target=print_two)
# thread_list.append(t)
#
# for t in thread_list:
# t.start()
# t.join() # 最后一个子线程结束后主线程才会结束
# print("当前线程名为:" + threading.current_thread().getName())
#################################################################################
# class WST():
# def __init__(self):
# self.session = requests.session()
#
# def do_login(self):
# # data = {}
# # res = self.session.post(url='xxx', data=data)
# # 断言
# #############
# print("0")
#
# # 循环次数
# def main_test(self):
# for i in range(5):
# self.do_login()
#
#
# if __name__ == '__main__':
# w = WST()
# # 并发数
# for i in range(10):
# threading.Thread(target=w.main_test()).start()
#######################################################################
# 客户端的资源使用率
import psutil
print("CPU使用率 内存使用率 C盘使用率")
delay = 2 # 隔两秒输出
while True:
time.sleep(delay)
print( str(psutil.cpu_percent()) + '% ' + str(psutil.virtual_memory().percent) + '% ' + str(psutil.disk_usage('C:\').percent) + '%')
原文地址:https://www.cnblogs.com/yaohu/p/12596932.html