python脚本将json文件生成C语言结构体

2023-11-13

1.引言

以前用过python脚本根据excel生成相关C语言代码,其实本质就是文件的读写,主要是逻辑问题,这次尝试将json文件生成C语言的结构体。

2.代码

这是一个json文件,生成这个结构体的本质是深度优先遍历,为了适应最复杂的情况,随便写了一个json文件(大家也可以根据需求自己改,我是自己写的,成功之后就去生产随机json的网站测试,目前没有啥问题,如果大家可以发现问题欢迎指出,在此感谢!)

{ 
    "BE1":{
        "apb_base_addr"  : "0x80000000",
        "stt_base_addr"  : "0x40000000",
        "size_type"      : {
            "REG": 64,
            "LUT": 64,
            "STT": 128
        },
        "module": [
            "BE_SYS", "BE_BIU",
            "DEC", "BLC", "LSC", "DGAIN", "AESTAT",
            "AWBSTAT", "AWB", "BDRC", "DM", "GAMMA",
            "RGBDITHER", "CSC", "SHP", "Y2RCSC", "CDS", "YUVDITHER","YUVDITHER"
        ],
        "nums": [
            1,2,6,4,3,6
        ],
        "tests" : [{"test1": 100, "test2": 200, "test3": 300 } ,
                   {"test1": 400, "test2": 500, "test3": 600 }],

        "repeat":{
                "a1" : {"test1": 100, "test2": 200, "test3": 300 } ,
                "b1" : {"test4": 400, "test5": 500, "test6": 600 }
        }
    },
    "PE1" : 0,

    "BE2":{
        "apb_base_addr"  : "0x80000000",
        "stt_base_addr"  : "0x40000000",
        "size_type"      : {
            "REG": 64,
            "LUT": 64,
            "STT": 128
        },
        "module": [
            "BE_SYS", "BE_BIU",
            "DEC", "BLC", "aaa", "qwe", "AESTAT",
            "AWBSTAT", "AWB", "BDRC", "DM", "GAMMA",
            "RGBDITHER", "abc", "SHP", "Y2RCSC", "CDS", "YUVDITHER","YUVDITHER"
        ],

        "nums": [
            1,2,3,4,5,6
        ],

        "tests" : [{"test1": 100, "test2": 200, "test3": 300 } ,
                   {"test1": 400, "test2": 500, "test3": 600 }],

        "repeat":{
                "a1" : {"test1": 100, "test2": 200, "test3": 300 } ,
                "b1" : {"test4": 400, "test5": 500, "test6": 600 }
        }
    },
    "PE2" : 0
}

python脚本:
json解析代码:

#################################################################################
# Company: 
# Engineer: 

# Create Date: 2022/7/25
# Project Name:
# Design Name:
# Module Name: json_parse
# Description:
#      parse json file
# Dependencies:
#
# Record:
#  Revision     Date        Description
#    v0.1     2022/7/25     parse json
# Additional Comments:
##################################################################################


import json

def is_addr(addr):
    return (addr.find("0x") == 0) and (addr[2:-1].isdigit())

def is_array(node):
    if ((node.find("{") != -1) and (node.find("}") != -1)):
        if ((node.find("[") != -1) and (node.find("]") != -1)
                and (node.find("}") + 1 == node.find("["))):
            return True
        if ((node.find("(") != -1) and (node.find(")") != -1)
                and (node.find("}") + 1 == node.find("["))):
            return True
    return False

def is_number(value):
    return value.isdigit()

def is_struct_array(node, member_list):
    if((is_array(node)) and (member_list[-1] != node)):
        return True
    return False

def is_number_array(node, member_list):
    if((is_array(node)) and (member_list[-1] == node)):
        return True
    return False

def load_json(fp):
    try:
        data = json.load(fp)
    except Exception as e:
        print("This is not a json file! %s" % e)
        return ""
    return data

def analyze_data(data, result, members):
    if isinstance(data, dict):
        for k, v in data.items():
            analyze_data(v, result + "->get{\"%s\"}" % str(k), members)
    elif isinstance(data, (list, tuple)):
        for i in range(len(data)):
            analyze_data(data[i], result + "[%s]" % i, members)
    else:
        members.append(result + "=" + str(data))

def get_members(fp, members):
    data = load_json(fp)
    if data != "":
        analyze_data(data, "{\"json_config\"}", members)

def get_max_depth(members):
    max_depth = 0
    for i in members:
        max_depth = max(max_depth, len(i.split("->")) - 1)

    return max_depth

def get_member_lists(members_array):
    member_lists = []
    for member in members_array:
        member_list = member.split("->")
        member_lists.append(member_list)
    return member_lists

def get_node_name(node, format):
    node_name_first = node.find("{\"") + 2
    node_name_end = node.find("\"}")
    node_name = node[node_name_first:node_name_end]
    if format == "array":
        if ((node.find("[") != -1
             and
             node.find("]") != -1)):
            index_1 = node.find("[") + 1
            index_2 = node.find("]")
            node_name += "[" + node[index_1:index_2] + "]"
    return node_name

def get_array_index(node):
    index_left = node.find("[") + 1
    index_right = node.find("]")
    array_index = node[index_left:index_right]
    return array_index


def check_value(value):
    if value.count(".") != 1:
        if value.isdigit():
            return "int"
        elif value.count("-") == 1 and value.startswith("-"):
            num = value.split("-")[-1]
            if num.isdigit():
                return "int"
            else:
                return check_bool(value)
        else:
            return check_bool(value)
    else:
        left = value.split(".")[0]
        right = value.split(".")[1]
        if right.isdigit():
            if left.isdigit():
                return "double"
            elif left.count("-") == 1 and left.startswith("-"):
                left_num = left.split("-")[-1]
                if left_num.isdigit():
                    return "double"
                else:
                    return check_bool(value)
            else:
                return check_bool(value)
        else:
            return check_bool(value)

def check_bool(value):
    if value.title() in ("True", "On"):
        return "bool"
    elif value.title() in ("False", "Off"):
        return "bool"
    elif is_addr(value):
        return "unsigned int"
    else:
        return "char *"

def get_type(node, member_list):
    if is_number_array(node, member_list):
        value = node.split("=")[-1]
        return "array " + check_value(value)

    if(node.find("=") != -1):
        value = node.split("=")[-1]
        return check_value(value)

    if is_struct_array(node, member_list):
        for i, temp in enumerate(member_list):
            if(temp == node):
                node_child = member_list[i+1]
                return "array " + "struct " + get_node_name(node, "") + "_s"

    return "struct " + get_node_name(node, "") + "_s"

def find_fathers(node_pre_names, node_name, node_father_names):
    node_pres = node_father_names.get(node_name, False)
    if (node_pres):
        for i in node_pres:
            if i== node_pre_names:
                return True
    return False



def get_node_info_list(member_lists):
    node_info_list = []
    node_father_names = {}
    row = len(member_lists)

    flag = 0  # json
    for i, member_list in enumerate(member_lists):
        for j, node in enumerate(member_list):

            node_info = {}
            node_name = get_node_name(node, "")
            node_pre_names = []
            node_pres = []
            if j == 0 and flag == 1:
                continue

            # root
            if j == 0:
                node_info["name"] = node_name
                child_names = []
                node_info["value"] = ""
                child_type = {}

                number = 0
                if node.find("[") != -1 and node.find("]") != -1:
                    index_l = node.find("[")
                    index_r = node.find("]")
                    last_node = member_lists[-1][0]
                    number = max(number, int(last_node[index_l + 1: index_r]))

                for index in range(i, row):
                    if (len(member_lists[index]) <= j):
                        break
                    if (member_lists[index][j] != node):
                        break

                    node_child = member_lists[index][j + 1]
                    child_name = get_node_name(node_child, "")
                    child_names.append(child_name)
                    child_type[child_name] = get_type(node_child, member_lists[index])

                child_names = list(set(child_names))

                node_info["child_name"] = child_names
                node_info["child_num"] = len(child_names)
                node_info["child_type"] = child_type
                node_info["self_type"] = "struct " + node_name + "_s"
                node_info["depth"] = j
                node_info["json_number"] = number
                node_info_list.append(node_info)
                flag = 1
                continue

            index = j - 1
            while (index >= 0):
                node_pre_name = get_node_name(member_list[index], "array")
                node_pre_names.append(node_pre_name)
                index -= 1

            if (j > 0
                    and
                (not find_fathers(node_pre_names, node_name, node_father_names))
                    ) :
                node_info["name"] = node_name
                node_info["father_name"] = node_pre_names
                node_pres.append(node_pre_names)
                node_father_names[node_name] = node_pres

                # leaf node (array)
                if (is_number_array(node, member_list)):
                    node_value_list = []
                    for index in range(i, row):
                        if (len(member_lists[index]) <= j):
                            break

                        if (get_node_name(member_lists[index][j], "") != node_name):
                            break
                        node_value_list.append(member_lists[index][j][member_lists[index][j].find("=") + 1:])

                    node_info["value"] = node_value_list
                    for i in node_value_list:
                        node_info["self_type"] = "array " + check_value(i)
                        break

                    node_info["child_num"] = len(node_value_list)
                    node_info["depth"] = j
                    node_info_list.append(node_info)
                    continue

                # leaf node (value)
                if (node.find("=") != -1):
                    node_value = node[node.find("=") + 1:]
                    node_info["value"] = node_value
                    node_info["self_type"] = get_type(node, member_list)
                    node_info["depth"] = j
                    node_info_list.append(node_info)

                    continue

                # struct array
                if (is_struct_array(node, member_list)):
                    child_names = []
                    node_info["value"] = ""
                    child_type = {}
                    arr_index = "0"

                    for index in range(i, row):
                        if (len(member_lists[index]) <= j):
                            break
                        if (get_node_name(member_lists[index][j], "") != node_name):
                            break

                        arr_index = get_array_index(member_lists[index][j])
                        node_child = member_lists[index][j + 1]
                        child_name = get_node_name(node_child, "")
                        child_names.append(child_name)
                        child_type[child_name] = get_type(node_child, member_list)
                        node_info["self_type"] = "array " + "struct " + node_name + "_s"

                    child_names = list(set(child_names))
                    node_info["child_name"] = child_names
                    node_info["child_num"] = int(arr_index) + 1
                    node_info["child_type"] = child_type
                    node_info["depth"] = j
                    node_info_list.append(node_info)

                    continue

                # dict json
                child_names = []
                node_info["value"] = ""
                child_type = {}

                for index in range(i, row):
                    if (len(member_lists[index]) <= j):
                        break
                    if (member_lists[index][j] != node):
                        break
                    node_child = member_lists[index][j + 1]
                    child_name = get_node_name(node_child, "")
                    child_names.append(child_name)
                    child_type[child_name] = get_type(node_child, member_lists[index])

                child_names = list(set(child_names))
                node_info["child_name"] = child_names
                node_info["child_num"] = len(child_names)
                node_info["child_type"] = child_type
                node_info["self_type"] = "struct " + node_name + "_s"
                node_info["depth"] = j
                node_info_list.append(node_info)
    return node_info_list


def get_nodes_info_from_jsonFile(file_path):
    members_array = []
    with open(file_path, "r+") as fp:
        get_members(fp, members_array)
        max_depth = get_max_depth(members_array)
        member_lists = get_member_lists(members_array)
        node_info_list = get_node_info_list(member_lists)
        return (node_info_list, max_depth)

代码生成部分:

#################################################################################
# Company: 
# Engineer: 

# Create Date: 2022/7/25
# Project Name:
# Design Name:
# Module Name: gen_code
# Description:
#      gen header file and config file from json file
# Dependencies:
#
# Record:
#  Revision     Date        Description
#    v0.1     2022/7/25     File Created
# Additional Comments:
##################################################################################

from utils.json_parse import *

def get_nodeinfo_dict(node_info_list):
    node_info_dict = {}

    for i in node_info_list:
        data_list = []
        name = i["name"]
        if(node_info_dict.get(name)):
            data_list = node_info_dict.get(name)
        data_list.append(i)
        node_info_dict[name] = data_list
    return  node_info_dict

def gen_struct(node_info, node_info_dict, fp):
    node_name = node_info["name"]
    fp.write(
        '/* Define the struct %s_s */\n' %node_name +
        'struct %s_s\n' %node_name +
        '{\n'
    )
    child_names = node_info["child_name"]
    child_types = node_info["child_type"]
    for child_name in child_names:
        child_type = child_types[child_name]

        # if array
        if (child_type.find("array") != -1):

            # find same node
            index = 0
            for i, j in enumerate(node_info_dict[child_name]):
                if j["name"] == node_name \
                        and j["self_type"] == node_info["self_type"] \
                        and j["child_types"] == node_info["child_types"]:
                    index = i
            child_child_num = node_info_dict[child_name][index]["child_num"]

            child_name += "[" + str(child_child_num) + "]" + ";"
            child_type = child_type.lstrip("array ")
            fp.write(
                '\t%s\t' % child_type.ljust(20) +
                child_name.ljust(30)
                + ' /* '.ljust(5) + child_name.rsplit(";")[0].ljust(15) + ' */\n'
            )
            continue

        child_name += ";"
        fp.write(
            '\t%s\t' % child_type.ljust(20) +
            child_name.ljust(30)
            + ' /* '.ljust(5) + child_name.rsplit(";")[0].ljust(15)  + ' */\n'
        )
    fp.write(
        '}; \n\n'
    )

def get_depth_list(node_info_list, max_depth):
    depth_list = [[] for x in range(max_depth)]
    for node_info in node_info_list:
        depth = node_info["depth"]
        depth_list[depth-1].append(node_info)

    return depth_list

def is_same_father(node1, node2):
    if(node1["father_name"] == node2["father_name"]):
        return True
    return False

# not same node but same name and type
def is_same_name_and_type(gened_nodes, node):
    node_name = node["name"]
    processed = gened_nodes.get(node_name, False)
    if(not processed):
        if(not is_same_father(processed, node)
                and
            processed["self_type"] == node["self_type"]):
            return True
    return False

def is_same_struct(gened_nodes, node):
    node_name = node["name"]
    processed = gened_nodes.get(node_name)
    if (processed != None):
        processed = gened_nodes.get(node_name)
        if processed["child_type"] == node["child_type"]:
            return True

    return False

def get_father_str(node_info):
    if(node_info["value"] != ""):
        fathers = list(reversed(node_info["father_name"]))
        name = node_info["name"]

        ret = ""
        for val in fathers:
            ret += val + "."

        # array
        if (node_info["self_type"].find("array") != -1):
            temp_name = ""
            for val in fathers:
                if(val.find("[") != -1 and val.find("]") != -1):
                    index_left = val.find("[")
                    index_right = val.find("]")
                    val = val[:index_left] + val[index_left+1:index_right]
                temp_name += val + "_"
            temp_name += name


            if(node_info["self_type"].find("*") != -1):
                temp = node_info["self_type"].lstrip("array ") + temp_name
            else:
                temp = node_info["self_type"].lstrip("array ") + " " + temp_name
            child_num = node_info["child_num"]
            temp += "[" + str(child_num) + "]" + " = " + "{"
            value_list = node_info["value"]

            for i, j in enumerate(value_list):
                if (i == len(value_list) - 1):
                    if (check_value(value_list[0]) != "char *"):
                        temp += j
                    else:
                        temp += "\"" + j + "\""
                    continue
                if (check_value(value_list[0]) != "char *"):
                    temp += j + ", "
                else:
                    temp += "\"" + j + "\""+ ", "
            temp += "};\n\t"

            ret += name
            ret = temp + "memcpy(" + temp_name + ", " + ret + ", sizeof(" + temp_name + "));"
            return ret

        # not array
        val = node_info["value"]
        if (check_value(val) != "char *"):
            if(val == "True"):
                val = "true"
            if(val == "False"):
                val = "false"
        else:
            val = "\"" + val + "\""
        ret += name + " = " + val +";"
        return ret
    return

def define_struct(node_info_dict, fp):
    node_info_config = node_info_dict["json_config"][0]
    if (node_info_config["json_number"] != 0):
        json_number = node_info_config["json_number"]
        fp.write("\t%s %s[%s];\n" % (node_info_config["self_type"],
                                     node_info_config["name"],
                                     str(json_number + 1)))
    else:
        fp.write("\t%s %s;\n" % (node_info_config["self_type"], node_info_config["name"]))

def generate_struct_h(gened_nodes, node_info_list, node_info_dict, fp):
    fp.write("#ifndef __JSON_CONFIG_H\n")
    fp.write("#define __JSON_CONFIG_H\n")
    fp.write("#include <stdio.h>\n")
    fp.write("#include <stdlib.h>\n")
    fp.write("#include <string.h>\n\n")

    for node_info in node_info_list:
        node_name = node_info["name"]
        if node_info["value"] == "":
            # not generated
            if not is_same_struct(gened_nodes, node_info):
                gen_struct(node_info, node_info_dict, fp)
                gened_nodes[node_name] = node_info

    node_info_config = node_info_dict["json_config"][0]
    if (node_info_config["json_number"] != 0):
        fp.write("%s *config_init(void);\n" %node_info_config["self_type"])
    else:
        fp.write("%s config_init(void);\n" %node_info_config["self_type"])

    fp.write("#endif")

def generate_struct_init(node_info_dict, node_info_list, fp):
    node_info_config = node_info_dict["json_config"][0]
    fp.write("#include \"json_config.h\" \n\n")  # TODO
    if (node_info_config["json_number"] != 0):
        fp.write("%s *config_init(void)\n" %node_info_config["self_type"])
    else:
        fp.write("%s config_init(void)\n" %node_info_config["self_type"])

    fp.write("{\n")

    # define struct
    define_struct(node_info_dict, fp)

    for node_info in node_info_list:
        ret = get_father_str(node_info)
        if ret == None:
            continue
        fp.write("\t" + ret + "\n")

    fp.write("\treturn %s;\n" %node_info_config["name"])

    fp.write("}\n")

def generate_test(node_info_dict, test_path):
    with open(test_path, "w") as fp:
        fp.write("//******************************************************************************\n\
// Copyright     :  Copyright (C) 2022, NIOd.\n\
// File name     :  json_test.c \n\
// Author        :  yoshi.shao   \n\
// Version       :  1.0         \n\
// Date          :  2022-07-25    \n\
// Description   :  test  \n\
// History       :         \n\
//******************************************************************************\n\n")

        fp.write("#include \"json_config.h\"\n\n")
        fp.write("int main(void)\n{\n")
        node_info_config = node_info_dict["json_config"][0]

        if (node_info_config["json_number"] != 0):
            fp.write("\t%s *%s = " % (node_info_config["self_type"], node_info_config["name"]))
        else:
            fp.write("\t%s %s = " % (node_info_config["self_type"], node_info_config["name"]))

        fp.write("config_init();\n")
        fp.write("\treturn 0;\n")
        fp.write("}\n")

def generate_all(json_path, file_path, init_path, test_path):
    (node_info_list, max_depth) = get_nodes_info_from_jsonFile(json_path)

    node_info_dict = get_nodeinfo_dict(node_info_list)
    node_info_list = list(reversed(node_info_list))

    gened_nodes = {}

    # generate struct.h
    with open(file_path, "w") as fp:
        fp.write("//****************************************************************************** \n\
// Copyright     :  Copyright (C) 2022, NIOd.\n\
// File name     :  json_config.h      \n\
// Author        :  yoshi.shao        \n\
// Version       :  1.0  \n\
// Date          :  2022-07-25     \n\
// Description   :  Define all struct   \n\
// History       :          \n\
//******************************************************************************\n\n")
        generate_struct_h(gened_nodes, node_info_list, node_info_dict, fp)
    with open(init_path, "w") as fp:
        fp.write("//******************************************************************************\n\
// Copyright     :  Copyright (C) 2022, NIOd.\n\
// File name     :  json_config.c \n\
// Author        :  yoshi.shao   \n\
// Version       :  1.0         \n\
// Date          :  2022-07-25    \n\
// Description   :  init json struct  \n\
// History       :         \n\
//******************************************************************************\n\n")
        generate_struct_init(node_info_dict, node_info_list, fp)

    generate_test(node_info_dict, test_path)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python脚本将json文件生成C语言结构体 的相关文章

随机推荐

  • 如何实现在一个 Socket 应用程序中同时支持 IPv4 和 IPv6

    如何实现在一个 Socket 应用程序中同时支持 IPv4 和 IPv6 如何巧妙地设计代码结构 陈 鲁 软件工程师 IBM 孙 妍 软件工程师 IBM 简介 当今的网络主流是 IPv4 网络 但随着 IP 地址的日益短缺 IPv6 网络开
  • JSP页面获取cookie内容

    当使用jsp技术时会用到cookie保存一些信息 在后端逻辑代码设置cookie Cookie name new Cookie uname na Cookie pwd new Cookie upwd pw 设置最大存活时间180s name
  • vue之路由配置中的meta

    仅对以前所学做复习记录使用 meta 数据的元数据 也就是程序员可以自己自定义的一些变量
  • 5G QoS管理及与DRB映射关系

    前言 无线网络是一个等级森严的体系 一直以来 无线资源都是紧张的 因而无线网络上的各种业务所享受的服务也无法平等 网络需要优先保障重要的业务 比如 相比普通上网的数据业务 音视频数据业务的优先级会更高 相比音视频数据业务 语音通话的优先级会
  • JVM对象内存布局

    HotSpot虚拟机中 对象在内存中的存储布局分3部分 对象头 实例数据 对齐填充 一 对象头 对象头包含两部分信息 对象的运行时数据和类型指针 1 对象的运行时数据 对象的运行时数据非常多 主要有哈希码 GC分代年龄 锁状态标志 线程持有
  • VMware虚拟机安装Linux系统教程(图文详解)

    一 安装 VMware 1 VMware虚拟机下载 链接 https pan baidu com s 1TElrJharG7jX25D9QO2Iyw pwd 5a8n 提取码 5a8n 安装 选一下安装地址 一直下一步即可 可能会要求重启电
  • Yii Framework 开发教程(30) Zii组件-ListView 示例

    CListView可以用来显示列表 CListView支持使用自定义的View模板显示列表的的记录 因此可以非常灵活的显示数据的表 这点有点像Android的ListView CListView 支持分页和排序 分页和排序支持使用AJAX实
  • vue项目部署到服务器打不开,Vue 项目部署到服务器的问题解决方法_盂希_前端开发者...

    相信很多小伙伴在用开发的时候 在 如何打包 基于 如何部署 将打包出来的 但有时候 我们会直接将dist文件扔到服务端 出现的问题 打包到服务器后 出现 打包到服务器后 出现空白页的问题 打包到服务器后 出现引入的 打包到服务器后 出现路由
  • MD5,SHA1,SHA256,NTLM,LM等Hash在线破解网站收集

    MD5 http hashchecker de find html http paste2 org p 441222 http r0ot podzemlje net x md5 http hashkiller com index php a
  • i春秋 从0到1CTFer成长之路-CTF中的SQL-1注入

    这是本萌新第一次写博客 作为对前面的学习的总结 如有错误 欢迎各位师傅们指正 如何判断注入类型我就不做过多的解释 不知道同学请移步去学习 手动狗头 CTF中的SQL注入 我采用的是手注 根据经验判断是字符型注入 接下来就来查看有几列 ord
  • 区块链学习7:超级账本项目Hyperledger与Fabric以及二者的关系

    前往老猿Python博文目录 一 超级账本 hyperledger 超级账本 hyperledger 是Linux基金会于2015年发起的推进区块链数字技术和交易验证的开源项目 成员包括金融 银行 物联网 供应链 制造和科技行业的领头羊 h
  • GBDT和随机森林的区别

    GBDT和随机森林的相同点 1 都是由多棵树组成 2 最终的结果都是由多棵树一起决定 GBDT和随机森林的不同点 1 组成随机森林的树可以是分类树 也可以是回归树 而GBDT只由回归树组成 2 组成随机森林的树可以并行生成 而GBDT只能是
  • 关注物联网、关注NB-IoT

    概述 关注物联网 关注NB IoT 跟紧时代步伐 让更多人深入理解5G用意 在当下情况下 今天就来来聊一聊NB IoT 特意整理了一些NB IoT的入门级问题 问 NB IoT的优势是什么 答 支持单小区50K用户连接 做上传用低功耗优势明
  • 【SpringBoot深入浅出系列】SpringBoot集成Eureka及Feign

    目录 前言 一 Eureka 是什么 二 Feign 是什么 三 集成步骤 1 创建 Eureka 服务注册中心 1 添加依赖 2 添加配置 3 启动类添加注解 4 启动服务 2 创建 SpringBoot 项目 provider 1 添加
  • MySQL图书管理系统设计

    目录 一 项目简介 二 项目分析 1 需求分析 图书管理功能 书籍的借出 归还 信息操作功能 人员管理功能 2 需求表信息分析 图书管理需求表分析 信息操作表信息分析 人员信息表 三 项目实施 1 创建图书信息表 2 创建人员信息表 3 创
  • SQL自学,mysql从入门到精通 --- 第 1 天,系统环境搭建,mysql部署

    1 SQL简介 SQL Structured Query Language 是一种用于管理和操作关系型数据库的编程语言 它被用于创建 修改和查询数据库 以及执行诸如数据插入 删除和更新等各种任务 SQL在Web开发 数据分析和数据库管理系统
  • vscode中设置字体大小_史上最全vscode配置使用教程

    点击上方蓝字 前端码头 一起玩耍 工欲善其事 必先利其器 想要优雅且高效的编写代码 必须熟练使用一款前端开发工具 但前端开发工具数不胜数 像HBuilder Sublime Text WebStorm Visual Studio Code
  • JSP( `EL表达式——获取数据` 和 `JSTL标签——展现数据`)(已被替代) 、 `MVC模式` 和 `三层架构`实现增删改查操作

    1 JSP 概述 JSP 全称 Java Server Pages Java 服务端页面 是一种动态的网页技术 其中既可以定义 HTML JS CSS等静态内容 还可以定义 Java代码的动态内容 也就是 JSP HTML Java JSP
  • 【Linux】Ubuntu开启root账户,以及后续连接MobaXterm

    一 开启root账户 1 首先在Ubuntu中打开终端 输入 sudo passwd root 完成root用户密码设置 效果如下图所示 2 输入下列代码 修改文件配置 sudo vim usr share lightdm lightdm
  • python脚本将json文件生成C语言结构体

    1 引言 以前用过python脚本根据excel生成相关C语言代码 其实本质就是文件的读写 主要是逻辑问题 这次尝试将json文件生成C语言的结构体 2 代码 这是一个json文件 生成这个结构体的本质是深度优先遍历 为了适应最复杂的情况