Python 框架学习 Django篇 (八) 代码优化、数据库冗余处理

我们开发软件系统的时候,需要不断的反思我们代码里面是否有可以优化的地方。而优化的重点之一,就是把冗余的代码优化为可以复用的库。我们在前面编写了一些功能,但是其中存在很多冗余的方法

mgr/medicine.py
mgr/k8s.py
mgr/medicine.py

打开这3个文件我们可以看到他们的入口函数dispatcher  实际的代码相似度非常高,该函数的大体代码基本类似,不同之处,只是分配给哪些函数处理

 

像这样的冗余代码如果持续增多,那么后续的维护成本也会变大,比如我想要将认证的返回值进行修改,那么我就需要去3个文件中挨个进行配置,所以我们要将这种相似的代码单独做成一个公共程序

一、冗余代码优化

1、添加公共函数目录

#在当前应用项目(mgr)下创建一个lib目录,并创建公共代码文件
lib
 |-handler.py

2、修改K8S.py存量代码

我们发现 请求消息给哪个函数处理, 完全是由 请求消息里面的action参数决定的, 所以,我们可以修改上面这3个代码文件,先删除原先的入口函数dispatcher函数(我前面几个定义的名称都不一致,这块可以改成一样的了)

#应用公共函数
from lib.handler import dispatcherBase

#当前函数所支持请求类型
Action2Handler = {
    'list_customer': listcustomers,
    'add_customer': addcustomer,
    'modify_customer': modifycustomer,
    'del_customer': deletecustomer,
}

def dispatcher(request):
    return dispatcherBase(request, Action2Handler)

我们定义一个什么样的action用什么函数处理的一张表 Action2Handler ,然后dispatcher 函数可以简单到直接调用 dispatcherBase, 并且把Action2Handler 作为参数传递给给它。剩下的就交由 dispatcherBase 去处理了,下面我们把原先的入口函数删除后,将上面的代码添加到3个文件最下面,注意修改Action2Handler变量中的请求参数和对应调用的函数名称

Django_demo/mgr/order.py

from django.http import JsonResponse
from django.db import  transaction
from django.db.models import F
# 导入 Order 对象定义
from  paas.models import  Order,OrderMedicine



def addorder(request):

    info  = request.params['data']

    # 从请求消息中 获取要添加订单的信息
    # 并且插入到数据库中


    with transaction.atomic():
        new_order = Order.objects.create(name=info['name'], customer_id=info['customerid'])

        batch = [OrderMedicine(order_id=new_order.id,medicine_id=mid,amount=1)
                 for mid in info['medicineids']]

        #  在多对多关系表中 添加了 多条关联记录
        OrderMedicine.objects.bulk_create(batch)


    return JsonResponse({'ret': 0,'id':new_order.id})

def listorder(request):
    # 返回一个 QuerySet 对象 ,包含所有的表记录
    qs = Order.objects \
        .annotate(
        customer_name=F('customer__name'),
        medicines_name=F('medicines__name')
    ) \
        .values(
        'id','name','create_date','customer_name','medicines_name'
    )

    # 将 QuerySet 对象 转化为 list 类型
    retlist = list(qs)

    # 可能有 ID相同,药品不同的订单记录, 需要合并
    newlist = []
    id2order = {}
    for one in retlist:
        orderid = one['id']
        if orderid not in id2order:
            newlist.append(one)
            id2order[orderid] = one
        else:
            id2order[orderid]['medicines_name'] += ' | ' + one['medicines_name']

    return JsonResponse({'ret': 0, 'retlist': newlist})




##################################新的入口函数################################



#添加导入公共函数
from .lib.handler import dispatcherBase

#传入本地函数和方法
Action2Handler = {
    'list_order': listorder,
    'add_order': addorder,
}
#重新定义入口函数
def dispatcher(request):
    return dispatcherBase(request, Action2Handler)

 3、定义公共函数

Django_demo/mgr/lib/handler.py

import json

from django.http import JsonResponse


def dispatcherBase(request,action2HandlerTable):
    # 根据session判断用户是否是登录的管理员用户
    if 'usertype' not in request.session:
        return JsonResponse({
            'ret': 302,
            'msg': '未登录',
            'redirect': '/mgr/sign.html'},
            status=302)

    if request.session['usertype'] != 'mgr':
        return JsonResponse({
            'ret': 302,
            'msg': '用户非mgr类型',
            'redirect': '/mgr/sign.html'},
            status=302)

    # 将请求参数统一放入request 的 params 属性中,方便后续处理

    # GET请求 参数 在 request 对象的 GET属性中
    if request.method == 'GET':
        request.params = request.GET

    # POST/PUT/DELETE 请求 参数 从 request 对象的 body 属性中获取
    elif request.method in ['POST','PUT','DELETE']:
        # 根据接口,POST/PUT/DELETE 请求的消息体都是 json格式
        request.params = json.loads(request.body)


    # 根据不同的action分派给不同的函数进行处理
    action = request.params['action']
    print(action)
    if action in action2HandlerTable:
        handlerFunc = action2HandlerTable[action]
        return handlerFunc(request)

    else:
        return JsonResponse({'ret': 1, 'msg': 'action参数错误'})

前面的认证转换和参数获取和之前的代码是一致的,区别在于获取到action参数后的操作

 # 根据不同的action分派给不同的函数进行处理
    action = request.params['action']
    if action in action2HandlerTable:
        handlerFunc = action2HandlerTable[action]
        return handlerFunc(request)

这段代码就是根据action参数的值,到 action2HandlerTable 查找出对应的 函数处理 ,可以根据这个方法去修改其他的两个代码文件

4、测试请求

import  requests,pprint

#添加认证
payload = {
    'username': 'root',
    'password': '12345678'
}
#发送登录请求
response = requests.post('http://127.0.0.1:8000/api/mgr/signin',data=payload)
#拿到请求中的认证信息进行访问
set_cookie = response.headers.get('Set-Cookie')




# 构建添加 客户信息的 消息体,是json格式
payload = {
    "action":"list_order",
}
url='http://127.0.0.1:8000/api/mgr/orders/'

if set_cookie:
    # 将Set-Cookie字段的值添加到请求头中
    headers = {'Cookie': set_cookie}

    # 发送请求给web服务
    response = requests.post(url,json=payload,headers=headers)
    pprint.pprint(response.json())

返回

{'ret': 0,
 'retlist': [{'create_date': '2023-10-26T01:15:09.718Z',
              'customer_name': 'zhangsan',
              'id': 13,
              'medicines_name': 'gmkl',
              'name': '天山订单'},
             {'create_date': '2023-10-26T01:14:29.897Z',
              'customer_name': 'zhangsan',
              'id': 12,
              'medicines_name': 'gmkl',
              'name': '天山订单'},
             {'create_date': '2023-10-26T01:13:35.943Z',
              'customer_name': 'zhangsan',
              'id': 11,
              'medicines_name': 'gmkl',
              'name': 'ts'},
             {'create_date': '2023-10-25T03:08:00Z',
              'customer_name': 'zhangsan',
              'id': 5,
              'medicines_name': 'gmkl',
              'name': 'test'}]}

5、补全其他案例

Django_demo/mgr/k8s.py


from django.http import JsonResponse

from paas.models import PaasInfo

def listcustomers(request):
    # 返回一个 QuerySet 对象 ,包含所有的表记录
    qs = PaasInfo.objects.values()

    # 将 QuerySet 对象 转化为 list 类型
    # 否则不能 被 转化为 JSON 字符串
    retlist = list(qs)

    return JsonResponse({'ret': 0, 'retlist': retlist})
def addcustomer(request):
    info = request.params['data']

    # 从请求消息中 获取要添加客户的信息
    # 并且插入到数据库中
    # 返回值 就是对应插入记录的对象
    record = PaasInfo.objects.create(ClusterName=info['ClusterName'] ,
                                     NodeSum=info['NodeSum'] ,
                                     PrometheusAddress=info['PrometheusAddress'])

    return JsonResponse({'ret': 0, 'id':record.id})
def modifycustomer(request):

    # 从请求消息中 获取修改客户的信息
    # 找到该客户,并且进行修改操作

    customerid = request.params['id']
    newdata    = request.params['newdata']
    print(customerid,newdata)

    try:
        # 根据 id 从数据库中找到相应的客户记录
        customer = PaasInfo.objects.get(id=customerid)
    except PaasInfo.DoesNotExist:
        return  {
            'ret': 1,
            'msg': f'id 为`{customerid}`的客户不存在'
        }


    if 'ClusterName' in  newdata:
        customer.ClusterName = newdata['ClusterName']
    if 'NodeSum' in  newdata:
        customer.NodeSum = newdata['NodeSum']
    if 'PrometheusAddress' in  newdata:
        customer.PrometheusAddress = newdata['PrometheusAddress']

    # 注意,一定要执行save才能将修改信息保存到数据库

    customer.save()

    return JsonResponse({'ret': 0})
def deletecustomer(request):
    customerid = request.params['id']

    try:
        # 根据 id 从数据库中找到相应的客户记录
        customer = PaasInfo.objects.get(id=customerid)
    except PaasInfo.DoesNotExist:
        return  {
            'ret': 1,
            'msg': f'id 为`{customerid}`的客户不存在'
        }

    # delete 方法就将该记录从数据库中删除了
    customer.delete()

    return JsonResponse({'ret': 0})


#重定义入口函数
from .lib.handler import dispatcherBase

Action2Handler = {
    'list_customer': listcustomers,
    'add_customer': addcustomer,
    'modify_customer': modifycustomer,
    'del_customer': deletecustomer,
}

def dispatcher(request):
    return dispatcherBase(request, Action2Handler)

Django_demo/mgr/medicine.py

from django.http import JsonResponse

# 导入 Medicine 对象定义(这块可能显示模块导入不正常,忽略)
from  paas.models import  Medicine

import json



def listmedicine(request):
    # 返回一个 QuerySet 对象 ,包含所有的表记录
    qs = Medicine.objects.values()

    # 将 QuerySet 对象 转化为 list 类型
    # 否则不能 被 转化为 JSON 字符串
    retlist = list(qs)

    return JsonResponse({'ret': 0, 'retlist': retlist})

def addmedicine(request):

    info    = request.params['data']

    # 从请求消息中 获取要添加客户的信息
    # 并且插入到数据库中
    medicine = Medicine.objects.create(name=info['name'] ,
                                       sn=info['sn'] ,
                                       desc=info['desc'])


    return JsonResponse({'ret': 0, 'id':medicine.id})

def modifymedicine(request):

    # 从请求消息中 获取修改客户的信息
    # 找到该客户,并且进行修改操作

    medicineid = request.params['id']
    newdata    = request.params['newdata']

    try:
        # 根据 id 从数据库中找到相应的客户记录
        medicine = Medicine.objects.get(id=medicineid)
    except Medicine.DoesNotExist:
        return  {
            'ret': 1,
            'msg': f'id 为`{medicineid}`的药品不存在'
        }


    if 'name' in  newdata:
        medicine.name = newdata['name']
    if 'sn' in  newdata:
        medicine.sn = newdata['sn']
    if 'desc' in  newdata:
        medicine.desc = newdata['desc']

    # 注意,一定要执行save才能将修改信息保存到数据库
    medicine.save()

    return JsonResponse({'ret': 0})

def deletemedicine(request):

    medicineid = request.params['id']

    try:
        # 根据 id 从数据库中找到相应的药品记录
        medicine = Medicine.objects.get(id=medicineid)
    except Medicine.DoesNotExist:
        return  {
            'ret': 1,
            'msg': f'id 为`{medicineid}`的客户不存在'
        }

    # delete 方法就将该记录从数据库中删除了
    medicine.delete()

    return JsonResponse({'ret': 0})




from .lib.handler import dispatcherBase

Action2Handler = {
    'list_medicine': listmedicine,
    'add_medicine': addmedicine,
    'modify_medicine': modifymedicine,
    'del_medicine': deletemedicine,
}

def dispatcher(request):
    return dispatcherBase(request, Action2Handler)

Django_demo/mgr/urls.py

from django.urls import path
from .views import login
from .sign_in_out import signin,signout

#重定义路由名称
from .k8s import dispatcher as k8s
from .order import dispatcher as order
from .medicine import dispatcher as medicine
urlpatterns = [
    path('customers/', k8s),
    path('medicines/', medicine),
    path('orders/', order),

    path('signin', signin),
    path('signout', signout),
    path('login',login)


]

二、数据库冗余

现在我们的 mgr/order.py 里面用 listorder 函数列出订单。如果一个订单里面有多个药品,就会产生多条记录。为了解决这个问题,我们不得不用python代码来处理冗余,像下面这样

def listorder(request):
    # 返回一个 QuerySet 对象 ,包含所有的表记录
    qs = Order.objects\
            .annotate(
                customer_name=F('customer__name'),
                medicines_name=F('medicines__name')
            )\
            .values(
                'id','name','create_date','customer_name','medicines_name'
            )

    # 将 QuerySet 对象 转化为 list 类型
    retlist = list(qs)

    # 可能有 ID相同,药品不同的订单记录, 需要合并
    newlist = []
    id2order = {}
    for one in retlist:
        orderid = one['id']
        if orderid not in id2order:
            newlist.append(one)
            id2order[orderid] = one
        else:
            id2order[orderid]['medicines_name'] += ' | ' + one['medicines_name']

    return JsonResponse({'ret': 0, 'retlist': newlist})

 这样做其实有一些问题,首先他会使得我们的代码增加了额外的去除重复记录的功能,并且还会代理性能问题,比如当大量用户登录时需要列出订单信息,需要服务程序从数据库获取到数据后,再去执行去除重复记录的任务

 1、冗余问题思路

我们可以修改数据库表的设计,就在订单表(order) 里面 直接存入订单包含的药品信息

这样就不用去关联表(orderMedicine) 去获取关联药品的信息,从而也不需要去除重复代码

这样,就不需要 从 OrderMedicine 表里面 去获取关联药品信息了,当然也不需要去除重复的代码了。

      但又有了新问题,如果说我们希望订单表里面有药品信息,需要有药品的id、名称、数量,而且有可能存在多种药品,关键是不同的订单和药品的数量也是不同的,对于这种情况,我们通常可以使用一个字段, 里面存储 json格式的字符串,记录可变数量的数据信息。

Django_demo/paas/models.py

class Order(models.Model):
    # 订单名
    name = models.CharField(max_length=200,null=True,blank=True)
    # 创建日期
    create_date = models.DateTimeField(default=datetime.datetime.now)
    # 客户
    customer = models.ForeignKey(Customer,on_delete=models.PROTECT)
    # 订单购买的药品,和Medicine表是多对多 的关系
    medicines = models.ManyToManyField(Medicine, through='OrderMedicine')



    # 为了提高效率,这里存放 订单 medicines 冗余数据
    medicinelist =  models.CharField(max_length=2000,null=True,blank=True)

 我们在订单表中添加了一个medicinelist的字段,里面用json格式来存储订单中的药品

[
    {"id": 1, "name": "青霉素", "amount": 20}, 
    {"id": 2, "name": "来适可", "amount": 100}
]


id 表示药品的id

name 表示 药品的名字

amount 表示 药品的数量

 上面的例子就表示该订单中有id 为 1 和 2 的两种药品 数量分别是 20 和 100

这个字段最大长度可达2000个字符,通常足以存储订单中的药品信息了

python manage.py makemigrations common
python manage.py migrate

2、修改接口参数

我们之前在请求接口的时候使用的是如下格式

{
    "action":"add_order",
    "data":{
        "name":"华山医院订单002",
        "customerid":3,
        "medicineids":[1,2]
    }
}

这里面只有药品的id,没有药品的 名称和数量。我们在开发的时候,经常会遇到当前的接口设计不能满足新的需求,需要修改的情况。这时候就要和 接口的设计者 , 以及接口对接的开发团队进行沟通, 说明为什么你需要修改接口

3、修改请求api格式

添加订单格式
{
    "action":"add_order",
    "data":{
        "name":"华山医院订单002",
        "customerid":3,
        "medicinelist":[
            {"id":16,"amount":5,"name":"环丙沙星"},
            {"id":15,"amount":5,"name":"克林霉素"}
        ]
    }
}
列出订单格式
    {
        "id": 2, 
        "name": "华山医院订单002", 
        "create_date": "2018-12-27T14:10:37.208Z", 
        "customer_name": "华山医院",
        "medicinelist":[
            {"id":16,"amount":5,"name":"环丙沙星"},
            {"id":15,"amount":5,"name":"克林霉素"}
        ]
    }

既然接口变动了,前端的开发团队 要根据修改后的接口,修改他们的代码,保证按照新的接口实现消息格式, 上面这个是前端发请求api所要携带的参数

4、修改后端代码逻辑

修改添加逻辑

Django_demo/mgr/order.py

def addorder(request):
    info = request.params['data']

    with transaction.atomic():
        medicinelist  = info['medicinelist']

        new_order = Order.objects.create(name=info['name'],
            customer_id=info['customerid'],

            # 写入json格式的药品数据到 medicinelist 字段中
            medicinelist=json.dumps(medicinelist,ensure_ascii=False),)

        batch = [OrderMedicine(order_id=new_order.id,
                               medicine_id=medicine['id'],
                               amount=medicine['amount'])
                 for medicine in medicinelist]

        OrderMedicine.objects.bulk_create(batch)

    return JsonResponse({'ret': 0, 'id': new_order.id})
修改列出表逻辑

Django_demo/mgr/order.py

def listorder(request):
    qs = Order.objects \
        .annotate(
                customer_name=F('customer__name')
        )\
        .values(
        'id', 'name', 'create_date',
        'customer_name',
        'medicinelist'
    )

    # 将 QuerySet 对象 转化为 list 类型
    retlist = list(qs)

    return JsonResponse({'ret': 0, 'retlist': retlist})

5、添加数据

import  requests,pprint

#添加认证
payload = {
    'username': 'root',
    'password': '12345678'
}
#发送登录请求
response = requests.post('http://127.0.0.1:8000/api/mgr/signin',data=payload)
#拿到请求中的认证信息进行访问
set_cookie = response.headers.get('Set-Cookie')




# 构建添加 客户信息的 消息体,是json格式
payload = {
    "action":"add_order",
    "data":{
        "name":"华山医院订单002",
        "customerid":1,
        "medicinelist":[
            {"id":6,"amount":5,"name":"gmkl"},
        ]
    }
}
url='http://127.0.0.1:8000/api/mgr/orders/'

if set_cookie:
    # 将Set-Cookie字段的值添加到请求头中
    headers = {'Cookie': set_cookie}

    # 发送请求给web服务
    response = requests.post(url,json=payload,headers=headers)
    print(response)

注意

payload = {
    "action":"add_order",
    "data":{
        "name":"华山医院订单002",
        "customerid":1,
        "medicinelist":[
            {"id":6,"amount":5,"name":"gmkl"},
        ]
    }
}

因为我们是要添加订单,所以客户id ("customerid":1,)  和药品id + 名称是必须要先知道的,或者我们在发起请求的时候不带这种id,去到后端的时候去根据数据库查询客户和药品的id再写入

6、调用查询数据

import  requests,pprint

#添加认证
payload = {
    'username': 'root',
    'password': '12345678'
}
#发送登录请求
response = requests.post('http://127.0.0.1:8000/api/mgr/signin',data=payload)
#拿到请求中的认证信息进行访问
set_cookie = response.headers.get('Set-Cookie')




# 构建添加 客户信息的 消息体,是json格式
payload = {
    "action":"list_order",
    "data":{
        "customer_name":"华山医院订单002",

    }
}
url='http://127.0.0.1:8000/api/mgr/orders/'

if set_cookie:
    # 将Set-Cookie字段的值添加到请求头中
    headers = {'Cookie': set_cookie}

    # 发送请求给web服务
    response = requests.post(url,json=payload,headers=headers)
    pprint.pprint(response.json())

返回

             {'create_date': '2023-11-02T09:05:27.095Z',
              'customer_name': 'zhangsan',
              'id': 19,
              'medicinelist': '[{"id": 6, "amount": 5, "name": "gmkl"}]',
              'name': '华山医院订单002'}]}

7、关于前后方案的

   上面这么做的好处很明显,列出订单的代码就比较简单了,不需要执行去重的任务。

性能也提高了, 只要查询一张表,并且不要执行去重的任务,但是有可能出现其他的问题

   

     冗余数据,我们本来记录在 OrderMedicine 表 中的, 现在我们还需要记录在 Order 表中,这么一说咋还不如之前的方法呢? 这样每次需要写两张表的性能反而是下降了吧

   但是除此之外还需要考虑到,是修改订单的请求多,还是查询订单的请求多,那么一定是查询的要多很多,每次查询都要跑去重,和只有修改的时候才会写两张表之间选择,肯定是后者的方案更好

     

     可能有小伙伴觉得,写两张表还更麻烦了,反正订单里面有药品信息,那么干脆不用OrderMedicine表不就更简单了吗,这样做,最大的问题是, 如果以后我们需要统计药品被采购的信息就非常麻烦了,因为,现在我们在数据库中存储的订单中的药品信息,是以字符串类型存储的 json信息,不能直接使用SQL语句进行过滤查询,只能把所有的记录读取出来进行分析,那样性能会非常低

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/114717.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

从科幻走向现实,LLM Agent 做到哪一步了?

LLM 洪流滚滚,AI 浪潮席卷全球,在这不断冲击行业认知的一年中,Agent 以冉冉新星之态引起开发者侧目。OpenAI 科学家 Andrej Karpathy 曾言“OpenAI 在大模型领域快人一步,但在 Agent 领域,却是和大家处在同一起跑线上。…

造物者:专注游戏音乐创造——奏响游戏世界乐章

游戏的世界宛如一幅壮丽的画卷,由华丽的图像和引人入胜的故事构成,然而,其完美之作还有一部分不可或缺的元素,那就是音乐。在这个数字时代,北京造物者科技有限公司(以下简称造物者)正崭露头角&a…

IntelliJ IDEA Services工具栏运行不显示端口问题解决

问题 如Spring Boot服务启动时,端口不显示。 解决 1、 清理所有缓存 2、 关闭IntelliJ IDEA后,到C:\Users\(你自己的用户名)\AppData\Local\Temp路径把所有文件都删除,因为时一个缓存,不影响其他软件…

RHCSA --- 第二天

一、查看IP地址 [rootlocalhost ~] ip ad 对应四张网卡 第一张&#xff1a;环回网卡&#xff08;用于测试&#xff09; 第二张&#xff08;主要&#xff09;&#xff1a;以太网网卡&#xff08;ens160&#xff09; 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP>…

静态库的概念及影响

1、目标文件的生成&#xff1a; 由编译器针对源文件编译生成&#xff0c;生成的.o或者.so(动态库)或者.a(静态库)也可以看作是目标文件&#xff1b; 2、静态库的生成&#xff1a; 由给定的一堆目标文件以及链接选项&#xff0c;链接器可以生成两种库&#xff0c;分别是静态库…

双绞线(寻线仪,测线仪),光纤测试工具(红光笔,OTDR,光功率计)

网络测试方式&#xff1a; 根据测试中是否向被测网络注入测试流量&#xff0c;可以将网络测试方法分为主动测试和被动测试。 主动测试&#xff1a;利用测试工具有目的地主动问被测网络注入测试流量&#xff0c;根据测试流量的传送情况分析网络技术参数。优点是具备良好的灵活…

年底赶项目?买核心板送开发板!T113核心板2款芯片6种配置选择

全志T113系列芯片是目前比较受欢迎的国产入门级嵌入式工业芯片。米尔是基于T113芯片开发较早、提供配置最全的厂家&#xff0c;是目前唯一一家提供T113-S和T113-i两种芯片核心板的厂家。更好的消息是&#xff0c;T113-i的核心板兼容T113-S的核心板&#xff0c;同一个硬件设计&a…

pom.xml详解

我们在开发Java应用程序时&#xff0c;pom.xml文件是项目中的核心配置文件之一&#xff0c;它结合Maven实现对项目依赖的拉取&#xff0c;今天就详细了解一下pom.xml文件的配置 Maven是一种构建工具&#xff0c;它用于构建、管理和发布Java项目pom.xml文件包含了项目的所有重要…

当科技遇上神器:用Streamlit定制AI可视化问答界面

Streamlit是一个开源的Python库&#xff0c;利用Streamlit可以快速构建机器学习应用的用户界面。 本文主要探讨如何使用Streamlit构建大模型外部知识检索的AI问答可视化界面。 我们先构建了外部知识检索接口&#xff0c;然后让大模型根据检索返回的结果作为上下文来回答问题。…

浅谈无源供电无线测温在线监测系统应用方案

安科瑞 崔丽洁 摘要&#xff1a;无源供电无线测温在线监测系统是一种基于声表面波技术的测温技术&#xff0c;在变电站监测方面得到了很好的技术实践应用。本文对无源供电无线测温在线监测系统研究应用进行分析研究。 关键词&#xff1a;设备检测&#xff1b;无线测温。 引言 在…

行情分析——加密货币市场大盘走势(11.3)

大饼昨日与今日目前都是下跌态势&#xff0c;近期依然要保持逢低做多的策略。现在下跌&#xff0c;可以继续等待&#xff0c;也可以入场一部分仓位的多单&#xff0c;回调才是给机会上车。MACD日线来看&#xff0c;会继续回调&#xff0c;因此这个位置还是可以在等等。 以太昨日…

LeetCode题:21合并两个有序链表

21合并两个有序链表 题目描述 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例 1&#xff1a; 输入&#xff1a;l1 [1,2,4], l2 [1,3,4] 输出&#xff1a;[1,1,2,3,4,4]示例 2&#xff1a; 输入&#xff1a;l1 [], …

vcruntime140.dll无法继续执行代码修复教程

在计算机的世界里&#xff0c;我们经常会遇到各种各样的问题&#xff0c;其中之一就是“vcruntime140.dll缺失”。这个问题可能会影响到我们的正常使用&#xff0c;但是别担心&#xff0c;今天我就来给大家分享一下关于vcruntime140.dll缺失的4种修复方案。 首先&#xff0c;我…

mac下载安装jenkins

下载 https://get.jenkins.io/war/ 启动 使用命令行启动 java -jar jenkins.war 浏览器访问 IP:8080 或 localhost:8080 &#xff0c;对jenkins进行配置&#xff0c;刚开始需要输入密码 终端会展示密码和密码存放位置 jenkins插件下载地址&#xff0c; 下载后自行上传。 I…

【ChatGLM2-6B】P-Tuning训练微调

机器配置 阿里云GPU规格ecs.gn6i-c4g1.xlargeNVIDIA T4显卡*1GPU显存16G*1 准备训练数据 进入/ChatGLM-6B/ptuningmkdir AdvertiseGencd AdvertiseGen上传 dev.json 和 train.json内容都是 {"content": "你是谁", "summary": "你好&…

如何使用ps制作ico图标文件

如何使用ps制作ico图标文件 Chapter1 如何使用ps制作ico图标文件Chapter2 ICOFormat.8bi&#xff08;Photoshop Ico、Cur插件&#xff09;的下载使用1. ICOFormat.8bi的作用2. ICOFormat.8bi使用 Chapter3 ps手机计算机图标教程,手绘设计精美手机APP软件图标的PS教程步骤 01 制…

计算机网络-应用层

文章目录 应用层协议原理万维网和HTTP协议万维网概述统一资源定位符HTML文档 超文本传输协议&#xff08;HTTP&#xff09;HTTP报文格式请求报文响应报文cookie 万维网缓存与代理服务器 DNS系统域名空间域名服务器和资源记录域名解析过程递归查询迭代查询 动态主机配置协议&…

解决CSS中height:100%失效的问题

出现BUG的场景&#xff0c;点击退出到登录页面&#xff0c;发现高度不对 上面出现了一种只是占了内容的高度&#xff0c;没有占满100%&#xff0c;为什么会出现这种情况呐&#xff1f; 让div的height"100%"&#xff0c;执行网页时&#xff0c;css先执行到&#xff0…

华为OD机试 - 数组组成的最小数字 - 逻辑分析(Java 2023 B卷 100分)

目录 专栏导读一、题目描述二、输入描述三、输出描述四、解题思路五、Java算法源码六、效果展示1、输入2、输出3、说明 华为OD机试 2023B卷题库疯狂收录中&#xff0c;刷题点这里 专栏导读 本专栏收录于《华为OD机试&#xff08;JAVA&#xff09;真题&#xff08;A卷B卷&#…

YOLOv5:按每个类别的不同置信度阈值输出预测框

YOLOv5&#xff1a;按每个类别的不同置信度阈值输出预测框 前言前提条件相关介绍YOLOv5&#xff1a;按每个类别的不同置信度阈值输出预测框预测修改detect.py输出结果 验证修改val.py输出结果 参考 前言 由于本人水平有限&#xff0c;难免出现错漏&#xff0c;敬请批评改正。更…
最新文章