上传文件至「/」
This commit is contained in:
+8
-8
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
#v1
|
||||
HOUSE_FILE = "./data/houses.json"
|
||||
|
||||
def init_db():
|
||||
@@ -21,6 +22,7 @@ def write_houses(houses):
|
||||
with open(HOUSE_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(houses, f, ensure_ascii=False, indent=4)
|
||||
|
||||
#v2
|
||||
STACK_FILE = "./data/stack_data.json"
|
||||
|
||||
def init_stack_db():
|
||||
@@ -47,14 +49,11 @@ def write_stack(stack_type, new_stack):
|
||||
with open(STACK_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
# V3.0 字符串+数组:邻接矩阵数据读写
|
||||
# v3
|
||||
MATRIX_FILE = "./data/matrix.json"
|
||||
|
||||
def init_matrix_db():
|
||||
"""
|
||||
新增:初始化小区邻接矩阵文件
|
||||
存储所有小区名称列表 和 二维距离数组(邻接矩阵)
|
||||
"""
|
||||
"""初始化小区邻接矩阵文件"""
|
||||
os.makedirs("./data", exist_ok=True)
|
||||
if not os.path.exists(MATRIX_FILE):
|
||||
init_data = {
|
||||
@@ -65,13 +64,14 @@ def init_matrix_db():
|
||||
json.dump(init_data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
def read_matrix_data():
|
||||
"""V3.0新增读取小区列表和距离邻接矩阵"""
|
||||
"""读取小区列表和距离邻接矩阵"""
|
||||
init_matrix_db()
|
||||
with open(MATRIX_FILE, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
|
||||
def write_matrix_data(matrix_dict):
|
||||
"""V3.0新增保存小区列表和距离邻接矩阵"""
|
||||
"""保存小区列表和距离邻接矩阵"""
|
||||
init_matrix_db()
|
||||
with open(MATRIX_FILE, 'w', encoding='utf-8') as f:
|
||||
json.dump(matrix_dict, f, ensure_ascii=False, indent=4)
|
||||
json.dump(matrix_dict, f, ensure_ascii=False, indent=4)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user