import os
import json
import time
path = './'
path_merges = './results_merges'
file_list = os.listdir(path)
json_list = []
data_list = []
out_time = time.strftime("%m_%d_%H_%M")
for file in file_list:
if file.endswith(".json"):
json_list.append(file)
print(json_list)
print(f"json文件数量:{len(json_list)}")
i = 1
for json_file in json_list:
json_path = os.path.join(path, json_file)
with open(json_path, 'r') as f:
locals()['json_data' + str(i)]= f.read()
locals()['data_' + str(i)] = json.loads(locals()['json_data' + str(i)].strip())
data_list = data_list + list(locals()['data_' + str(i)].items())
i += 1
data = dict(data_list)
json_data = json.dumps(data, ensure_ascii=False)
if not os.path.exists(path_merges):
os.mkdir(path_merges)
with open(os.path.join(path_merges, f'merges_{out_time}.json'),"w") as f1:
f1.write(json_data)
2022-09-30 17:21
import turtle
t = turtle.Pen()
t.speed(0) #0:最快的 1:最慢的 5/10:比较快
t.width(3) #设置宽度
my_color = ("red","green","yellow","blue","purple")
for x in range(20):
t.goto(0,-(x-1)*20)
t.pendown()
t.color(my_color[x%len(my_color)]) #这样就可以不断的循环使用元组里的颜色
t.circle(x*20)
t.penup()
turtle.done()
2022-09-30 17:21
获取方式有很多种,比如(1) 借助handler,是介绍最多的一种方法,但是用起来比较麻烦;(2)使用response headers的set_cookie;(3)使用response的cookies属性获取
2022-09-30 17:20
在python3.6中安装openaxu;需要.下载numpy和opencv-python,根据已经安装的python版本号下载相对应的numpy和opencv_python。例如,python3.6是32位的,那么我就下载了相对应的opencv_python-3.4.1-cp36-cp36m-win32.whi和numpy-1.14.5+mkl-cp36-cp36m-win32.whl。如果python版本是64位的,就下载相对应的64位的numpy和opencv_python。下载完成后,按住win+R输入cmd进入命令行界面。将路径切换到已经下载的numpy和opencv_python的文件所在目录。然后输入pip install numpy-1.14.5+mK-cp36-cp36m-win32.whl和pip install opencv_进行安装
2022-09-30 17:20