16、监测数据采集物联网应用开发步骤(12.1)

阶段性源码将于本章节末尾给出下载

  1. 监测数据采集物联网应用开发步骤(11)

本章节进行前端web UI开发+web数据接口服务开发

web数据接口服务利用SOCKET TCP服务方式解析http协议内容模式

com.zxy.common.Com_Para.py中添加如下内容

#修改web数据接口服务端口
port = 9000
#是否启用http协议
bThread = True
#web数据接口访问函数名
Inf_Name = "CenterData"
#web文件后缀{}
web_Name = [".html", ".js", ".css", ".jpg", ".gif", ".png", ".svg", ".eot", ".ttf", ".woff2", ".woff", ".ico" ,".json", ".log",".xlsx",".xls",".vue",".dlls"]
#web数据接口返回值字段大小写,0不设置  1大写 2小写
iReturnUppLower = 1
#web数据接口TCP连接socket统计
socket_count = 0
#指定跨域访问IP xxx.xx.xx.xxx 默认为空
HttpUrl = ""
#上传文件后缀
attUpFile = ".txt|.zip|.rar|.tar|.json|.jpg|.bmp|.gif|.xls|.xlsx|.sql|.doc|.docx|"

com.zxy.common.Com_Fun.py中添加代码

            #web数据接口返回值参数大小写@staticmethoddef GetLowUpp(inputValue):if Com_Para.iReturnUppLower == 1:return inputValue.upper()elif Com_Para.iReturnUppLower == 2:return inputValue.lower()else:return inputValue

新建web数据接口返回格式类com.zxy.model.Return_Value.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2017年05月10日
@author: zxyong 13738196011
'''
from com.zxy.common.Com_Fun import Com_Fun#监测数据采集物联网应用--web数据接口返回格式
class Return_Value(object):attParam_name = "COMMOND_NAME"attS_result = 1attErr_desc = "成功"def __init__(self):passdef Back_Value(self):return "{\""+self.attParam_name+"\":[{\""+Com_Fun.GetLowUpp("s_result")+"\":\""+self.attS_result+"\",\""+Com_Fun.GetLowUpp("err_desc")+"\":\""+self.attErr_desc+"\"}]}"新建数据业务处理和获取类com.zxy.business.Ope_DB_Cent.py
#! python3
# -*- coding: utf-8 -
'''
Created on 2017年05月10日
@author: zxyong 13738196011
'''from com.zxy.adminlog.UsAdmin_Log import UsAdmin_Log
from com.zxy.common import Com_Para
from com.zxy.common.Com_Fun import Com_Fun
from com.zxy.db_Self.Db_Common_Self import Db_Common_Self
from com.zxy.z_debug import z_debug#监测数据采集物联网应用--数据业务处理、获取
class Ope_DB_Cent(z_debug):attICount = 0attS_result = 1def __init__(self):pass#带参数数据库读写
#     temSqlIns = "insert into xxx(x,x,x) values(?,?,?)
#     temParameters = []
#     temParamTypes = []
#     temParamOutName = []
#     temParamOutType = []
#     iIndex = 0
#     try:
#         temDb_self = Db_Common_Self()
#         temTpn = T_PROC_NAME()
#         temTpn.attINF_EN_SQL = temSqlIns        
#         temDb_self.Common_Sql_Proc("Ins_Data_JSON",temParameters,temParamTypes,temParamOutName,temParamOutType,temTpn)
#         #temSqlException = temDb_self.attSqlException
#         #temColumnNames = temDb_self.attColumnNames
#     except Exception as es:
#         temError = "get data error[Ins_Data_JSON]" +temSqlIns+") "+temstrSqlValues+")" +"\r\n"+repr(es)
#         uL = UsAdmin_Log(Com_Para.ApplicationPath, temError)
#         uL.WriteLog()#resultSet转Jsondef ResultSetToJson(self,input_sql):temDbSelf = Db_Common_Self()temRs = temDbSelf.Common_Sql(input_sql)temColumnNames = temDbSelf.attColumnNames        jsary1 = []try:for temItem in temRs:temjso1 = {}for i in range(0,len(temColumnNames)):if temItem[i] != "null":temjso1[Com_Fun.GetLowUpp(temColumnNames[i][0])] = temItem[i]else:temjso1[Com_Fun.GetLowUpp(temColumnNames[i][0])] = ""jsary1.append(temjso1)except Exception as e:temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+input_sql+"==>"+repr(e)self.debug_in(self,input_sql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info(self)+input_sql+"==>"+repr(e)self.debug_in(input_sql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()return jsary1#数据业务处理、获取def Cal_Data(self, inputSub_code, inputParam_name, inputAryParamValue, inputStrIP,inputSession_id,inputHtParam):temResult = ""if inputParam_name == "init_page":#写读取缓存内容return "{\"" + inputParam_name + "\":[{\""+Com_Fun.GetLowUpp("s_result")+"\":\"1\",\""+Com_Fun.GetLowUpp("error_desc")+"\":\"读取缓存信息成功!\"}]}"elif inputParam_name == "A01_AAA111":return "{\"" + inputParam_name + "\":[{\""+Com_Fun.GetLowUpp("s_result")+"\":\"1\",\""+Com_Fun.GetLowUpp("error_desc")+"\":\"后台获取的业务时间:"+Com_Fun.GetTimeDef()+"\"}]}"elif inputParam_name == "A01_AAA222":return "{\"" + inputParam_name + "\":[{\""+Com_Fun.GetLowUpp("s_result")+"\":\"1\",\""+Com_Fun.GetLowUpp("error_desc")+"\":\"后台获取的GUID:"+Com_Fun.Get_New_GUID()+"\"}]}"return temResult

新建web数据接口业务查询类com.zxy.business.Query_Data.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2017年05月10日
@author: zxyong 13738196011
'''from com.zxy.z_debug import z_debug
from com.zxy.model.Return_Value import Return_Value
from com.zxy.business.Ope_DB_Cent import Ope_DB_Cent#监测数据采集物联网应用--web数据接口业务查询
class Query_Data(z_debug):attSession_id    = ""attReturn_Value  = Return_Value()def __init__(self,inputReturn_Value):self.attReturn_Value = inputReturn_Value#后台数据处理def GetDataList(self,inputSub_code, inputSub_usercode, inputParam_name, inputAryParamValue, inputStrUrl, inputDelay_data, inputDelay_code, inputStrIP,inputHtParam):temOpd = Ope_DB_Cent()temResult = temOpd.Cal_Data(inputSub_code,inputParam_name,inputAryParamValue,inputStrIP,self.attSession_id,inputHtParam)return temResult新建web数据接口socket服务类com.zxy.tcp.ServerThreadHttp.py
#! python3
# -*- coding: utf-8 -
'''
Created on 2017年05月10日
@author: zxyong 13738196011
'''import socket,threading
from com.zxy.z_debug import z_debug
from com.zxy.tcp.ServerHandlerHttp import ServerHandlerHttp#监测数据采集物联网应用--web数据接口socket服务
class ServerThreadHttp(z_debug):attStrValue = ""attStrNum = ""attPort = 0def __init__(self, inputStrValue,inputNum,inputPort):self.attStrNum = inputNumself.attStrValue = inputStrValueself.attPort = inputPortdef run(self):temS = Nonetry:temS = socket.socket(socket.AF_INET, socket.SOCK_STREAM)temS.bind(('0.0.0.0', self.attPort))temS.listen(400)while True:try:sock,addr = temS.accept()sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)temServerHH = ServerHandlerHttp()temServerHH.attServSocket = socktemServerHH.attStrIP = addrt1 = threading.Thread(target=temServerHH.run, name="ServerHttpThread"+"_"+str(addr[0])+"_"+str(addr[1]))t1.start()except Exception as en:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(en)+"=>"+str(en.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(en)+"=>"+str(en.__traceback__.tb_lineno))#打印异常信息passexcept Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息pass 

新建web数据接口服务Handler类com.zxy.tcp.ServerHandlerHttp.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2017年05月10日
@author: zxyong 13738196011
'''import osfrom com.zxy.adminlog.UsAdmin_Log import UsAdmin_Log
from com.zxy.business.Query_Data import Query_Data
from com.zxy.common import Com_Para
from com.zxy.common.Com_Fun import Com_Fun
from com.zxy.model.Return_Value import Return_Value
from com.zxy.tcp.Request import Request
from com.zxy.z_debug import z_debug#监测数据采集物联网应用--web数据接口服务Handler
class ServerHandlerHttp(z_debug):attServSocket = NoneattStrIP = "0.0.0.0"attReturn_Value = Return_Value()attConnection = ""def __init__(self):passdef run(self):self.server_link()def server_link(self):Com_Para.socket_count = Com_Para.socket_count + 1if Com_Para.driverClassName == "org.sqlite.JDBC":self.init()else:self.init()Com_Para.socket_count = Com_Para.socket_count - 1#web文件内容加载,如:html css js......def webPage_Real(self,inputStrUrl,inputS_guid,inputPost_str,inputQuery_Data,inputReturnMessage,inputWeb_name):temFilePath = Com_Para.ApplicationPath +Com_Para.zxyPath+ "web"if inputWeb_name == ".log":temFilePath = Com_Para.ApplicationPathif inputStrUrl[0:10] =="/root_api/":temFUrl = inputStrUrl[10:inputStrUrl.index(inputWeb_name)]else:temFUrl = inputStrUrl[0:inputStrUrl.index(inputWeb_name)]temFilePath = temFilePath + Com_Para.zxyPath+temFUrltemFilePath = temFilePath + inputWeb_name        if os.path.exists(temFilePath):bVue = False#自定义页面组件后缀if inputStrUrl.find(".dlls") != -1 and inputStrUrl.find(".dlls") == len(inputStrUrl) - len(".dlls"):bVue = TruetemFile = Nonetry:temFile = open(file=temFilePath,mode='rb')                self.attServSocket.send((inputReturnMessage +"\r\n\r\n").encode(Com_Para.U_CODE))if bVue:self.attServSocket.send(b'ReadCommonRes("')while True:byt = temFile.read(1024)# 每次读取1024个字节if bVue :self.attServSocket.send(byt.replace(b'\t',b'').replace(b'\n',b'').replace(b'\r',b'').replace(b'\"',b'\\\"').replace(b'$',b'"'))else:self.attServSocket.send(byt)#字节形式发送数据                    if not byt: #如果没有读到数据,跳出循环breakif bVue:self.attServSocket.send(b'");')self.attServSocket.send("\r\n".encode(Com_Para.U_CODE))                except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息finally:if not temFile is None:temFile.close()else:temErrorMessage = "HTTP/1.1 404 File Not Found\r\n"temErrorMessage += "Content-Type: text/html\r\n"temErrorMessage += "Content-Length: 230\r\n"temErrorMessage += "\r\n" + "<h1>未找到正确页面</h1>"try:self.attServSocket.send(temErrorMessage.encode(Com_Para.U_CODE))self.attServSocket.send("\r\n".encode(Com_Para.U_CODE))except Exception as e:pass#解析http协议def SubAnalyseRecBytes(self,temRequest):temS_guid = "" temRequest.parse()self.attConnection = temRequest.attConnectiontemStrUrl = temRequest.attUritemPost_Str = temRequest.attPost_strself.attReturn_Value = temRequest.attRv        temReturnMessage = "HTTP/1.1 200 OK\r\n"if temStrUrl.find(".html") != -1 and temStrUrl.find(".html") == len(temStrUrl) - 5:temReturnMessage += "Content-Type: text/html\r\n"elif temStrUrl.find(".js") != -1 and temStrUrl.find(".js") == len(temStrUrl) - 3:temReturnMessage += "Content-Type: application/x-javascript\r\n"elif temStrUrl.find(".css") != -1 and temStrUrl.find(".css") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: text/css\r\n"elif temStrUrl.find(".jpg") != -1 and temStrUrl.find(".jpg") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: image/jpg\r\n"elif temStrUrl.find(".gif") != -1 and temStrUrl.find(".gif") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: image/jpg\r\n"elif temStrUrl.find(".png") != -1 and temStrUrl.find(".png") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: mage/png\r\n"elif temStrUrl.find(".svg") != -1 and temStrUrl.find(".svg") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: text/svg+xml\r\n"elif temStrUrl.find(".eot") != -1 and temStrUrl.find(".eot") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: application/vnd.ms-fontobject\r\n"elif temStrUrl.find(".ttf") != -1 and temStrUrl.find(".ttf") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: application/x-font-ttf\r\n"elif temStrUrl.find(".woff") != -1 and temStrUrl.find(".woff") == len(temStrUrl) - 5:temReturnMessage += "Content-Type: application/x-font-woff\r\n"elif temStrUrl.find(".woff2") != -1 and temStrUrl.find(".woff2") == len(temStrUrl) - 6:temReturnMessage += "Content-Type: application/x-font-woff\r\n"elif temStrUrl.find(".ico") != -1 and temStrUrl.find(".ico") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: image/ico\r\n"                elif temStrUrl.find(".log") != -1 and temStrUrl.find(".log") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: text\r\n"elif temStrUrl.find(".dlls") != -1 and temStrUrl.find(".dlls") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: application/x-javascript\r\n"elif temStrUrl.find(".vue") != -1 and temStrUrl.find(".vue") == len(temStrUrl) - 4:temReturnMessage += "Content-Type: application/x-javascript\r\n"else:temReturnMessage += "Content-Type: text/html\r\n"temReturnMessage += "Access-Control-Allow-Methods: POST,GET\r\n"temReturnMessage += "Access-Control-Allow-Origin:*" + Com_Para.HttpUrltemReturnMessage += "\r\n" + "Connection: Keep-Alive"temStrResult = "-1"temGd = Query_Data(self.attReturn_Value)#通用接口bWeb_Name =  Falsefor temAttF in Com_Para.web_Name:if temStrUrl.find(temAttF) != -1 and temStrUrl.find(temAttF) == len(temStrUrl) - len(temAttF) and temStrUrl.find("param_name=") == -1:self.webPage_Real(temStrUrl,temS_guid,temPost_Str,temGd,temReturnMessage,temAttF)bWeb_Name = Truebreakif bWeb_Name == True or temRequest.attUploadFile != "":passelif temStrUrl.find("sub_code=") != -1 and temStrUrl.find("param_name=") != -1:                temStrResult = self.Center_Data_Rel(temStrUrl,temS_guid,temPost_Str,temGd,temReturnMessage,temRequest.attStrIP[0])elif temStrUrl.strip() == "" and temStrUrl.strip().find("GET /favicon.ico HTTP/1.1") != -1:                temStrResult = self.Send_Error(temStrUrl,temS_guid,temPost_Str,temGd,temReturnMessage)elif temStrUrl.strip() != "":self.attServSocket.send((temReturnMessage+"\r\n\r\n请求错误接口或页面\r\n").encode(Com_Para.U_CODE))if temRequest.attUploadFile != "":self.attServSocket.send((temReturnMessage + "\r\n\r\n" + temRequest.attUploadFile  + "\r\n").encode(Com_Para.U_CODE))              elif temStrResult != "-1":self.attServSocket.send((temReturnMessage + "\r\n\r\n" + temStrResult + "\r\n").encode(Com_Para.U_CODE))              return temReturnMessage#初始化def init(self):try:temRequest = Request()temRequest.attServSocket = self.attServSockettemRequest.attStrIP = self.attStrIPself.attServSocket.setblocking(1)temReturnMessage = self.SubAnalyseRecBytes(temRequest)except Exception as e:self.attServSocket.send(temReturnMessage+"\r\n\r\n"+repr(e)+"\r\n".encode(Com_Para.U_CODE))temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+repr(e)self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+repr(e)self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()            finally:self.attServSocket.shutdown(1)self.attServSocket.close()def Send_Error(self,inputStrUrl,inputS_guid,inputPost_Str,inputGd,inputReturnMessage):inputReturnMessage = "Error请求语法错误"return inputReturnMessage#通用获取数据接口    def Center_Data_Rel(self,inputStrUrl, inputS_guid, inputPost_Str, inputGd, inputReturnMessage, inputStrIP):temStrAry = ""#<String,String>temHtParam = {}for temStrTemV in inputStrUrl.split("&"):temStrTemPar = temStrTemV.split("=")if len(temStrTemPar) == 2:Com_Fun.SetHashTable(temHtParam,temStrTemPar[0],temStrTemPar[1])else:Com_Fun.SetHashTable(temHtParam,temStrTemPar[0],"")temSub_code = Com_Fun.GetHashTable(temHtParam,"sub_code")temSub_usercode = Com_Fun.GetHashTable(temHtParam,"sub_usercode")temDelay_data = Com_Fun.GetHashTable(temHtParam,"delay_data")temDelay_code = Com_Fun.GetHashTable(temHtParam,"delay_code")temParam_name = Com_Fun.GetHashTable(temHtParam,"param_name")temSession_id = Com_Fun.GetHashTable(temHtParam,"session_id")temJsoncallback = Com_Fun.GetHashTable(temHtParam,"jsoncallback")self.attReturn_Value.attParam_name = temParam_name#传递in 参数<String>temAryParamValue = []for temTemstr in inputPost_Str:if temTemstr == "jsonpzxyong":temJsoncallback = temTemstr.split("=")[1]break#获取版本号if temParam_name == "get_version":temStrAry = "{\""+ temParam_name+ "\":[{\""+Com_Fun.GetLowUpp("s_result")+"\":\"1\",\""+Com_Fun.GetLowUpp("error_desc")+"\":\"\",\""+Com_Fun.GetLowUpp("version")+"\":\""+Com_Para.version+"\"}]}"#通用数据接口else:inputGd.attSession_id = temSession_idtemStrAry = inputGd.GetDataList(temSub_code,temSub_usercode,temParam_name,temAryParamValue,inputStrUrl,temDelay_data,temDelay_code,inputStrIP,temHtParam)if temJsoncallback != "":temStrAry = temJsoncallback + "("+temStrAry+")"if self.attReturn_Value.attS_result == 1:self.attReturn_Value = inputGd.attReturn_Value        temHtParam = None        return temStrAry

  1. 监测数据采集物联网应用开发步骤(12.2)

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

力扣labuladong——一刷day03

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、力扣LCR 140. 训练计划 II二、力扣LCR 142. 训练计划 IV三、力扣LCR 171. 训练计划 V四、力扣LCR 021. 删除链表的倒数第 N 个结点五、力扣LCR 022. 环形链…

使用Dockerfile生成docker镜像和容器的方法记录

一、相关介绍 Docker 是一个开源的容器化平台&#xff0c;其中的主要概念是容器和镜像。 容器是 Docker 的运行实例。 它是一个独立并可执行的软件包&#xff0c;包含了应用程序及其依赖的所有组件&#xff08;如代码、运行时环境、系统工具、库文件等&#xff09;。容器可以在…

我的电子萝卜刀火了吗?

引言 大家好&#xff0c;我是亿元程序员&#xff0c;一位有着8年游戏行业经验的主程。 笔者在上一篇文章《萝卜刀真的太危险了,于是我用Cocos做了一个》中说到因女儿从学校回来之后想要我给她买一把萝卜刀被我拒绝&#xff0c;但是又想要让她体验一下&#xff0c;因此用Cocos…

REDIS命令

常见文件名 Redis-cli使用命令 1、启动Redis2、连接Redis3、停止Redis4、发送命令 1、redis-cli带参数运行&#xff0c;如&#xff1a;2、redis-cli不带参数运行&#xff0c;如&#xff1a;5、测试连通性key操作命令 获取所有键查询键是否存在删除键查询键类型移动键查询key的生…

Howler.js HTML5声音引擎

介绍 Howler.js是一个不错的HTML5声音引擎。功能强大&#xff0c;性能不错&#xff0c;用起来也很方便。 1. 官网 https://howlerjs.com/ GitHub https://github.com/goldfire/howler.js 2. 兼容性 Howler默认使用Web Audio&#xff0c;但在IE上可以自动转为HTML 5 Audio。这…

零基础学python:错误与异常

嗨喽&#xff0c;大家好呀~这里是爱看美女的茜茜呐 语法错误 异常&#xff1a;大多数的异常都不会被程序处理&#xff0c;都以错误信息的形式展现在这里 &#x1f447; &#x1f447; &#x1f447; 更多精彩机密、教程&#xff0c;尽在下方&#xff0c;赶紧点击了解吧~ pyth…

Ubuntu源码编译samba

概述 本人最近研究samba的源码&#xff0c;但是在源码编译的时候&#xff0c;本以为直接config,make,make install。没想到编译过程中碰到很多麻烦&#xff0c;主要是各种依赖问题。 基于此&#xff0c;本文把samba编译的详细过程记录下来&#xff0c;以供再次研究借鉴。 软件…

力扣刷题 day50:10-20

1.存在重复元素 给你一个整数数组 nums 。如果任一值在数组中出现 至少两次 &#xff0c;返回 true &#xff1b;如果数组中每个元素互不相同&#xff0c;返回 false 。 方法一&#xff1a;集合去重 #方法一&#xff1a;集合去重 def containsDuplicate(nums):return len(n…

AWS SAA-C03考试知识点整理

S3&#xff1a; 不用于数据库功能 分类&#xff1a; S3 Standard &#xff1a;以便频繁访问 S3 Standard-IA 或 S3 One Zone-IA &#xff1a; 不经常访问的数据 Glacier&#xff1a; 最低的成本归档数据 S3 Intelligent-Tiering智能分层 &#xff1a;存储具有不断变化或未知访问…

KubeSphere一键安装部署K8S集群(单master节点)-亲测过

1. 基础环境优化 hostnamectl set-hostname master1 && bash hostnamectl set-hostname node1 && bash hostnamectl set-hostname node2 && bashcat >> /etc/hosts << EOF 192.168.0.34 master1 192.168.0.45 node1 192.168.0.209…

从零开始,学好 Python 从大一新生自我介绍开始

从零开始&#xff0c;学好 Python 从大一新生自我介绍开始 大家好&#xff0c;我叫xxx,今年18岁&#xff0c;刚刚入学不久。我决定从零开始系统学习Python编程语言。 Python是一种解释型、交互式和脚本编程语言。它由荷兰人Guido van Rossum在1991年左右创立&#xff0c;语法简…

Python学习第2天-安装pycharm

文章目录 前言一、下载二、安装1.选择安装目录2.安装配置 总结 前言 好用的工具可以极大地提高生产力&#xff0c;开发Python推荐使用jetbrains全家桶的pycharm。 一、下载 通过官网下载安装包。 二、安装 1.选择安装目录 2.安装配置 一路Next&#xff0c;安装完成 总结 …

模拟最终成绩计算过程

首先输入大于2的整数作为评委人数,然后依次输入每个评委的打分,要求每个分数介于0~100.输入完所有评委打分之后,去掉一个最高分,去掉一个最低分,剩余分数的平均分即为该选手的最终得分 (1) while True:try:n int(input(请输入评委人数:))assert n > 2# 跳出循环breakexce…

快速排序原理JAVA和Scala实现-函数式编程的简洁演示

快速排序原理JAVA和Scala实现-函数式编程的简洁演示 目录 快速排序原理JAVA和Scala实现-函数式编程的简洁演示 C语言快速排序实现 Java 快速排序实现 Scala 快速排序实现 本文章向大家介绍快速排序原理JAVA和Scala实现-函数式编程的简洁演示&#xff0c;主要内容包括C语言…

在Ubuntu上安装和挂载NFS

在Ubuntu上安装和挂载NFS可以按照以下步骤进行&#xff1a; 安装NFS客户端工具&#xff1a;在Ubuntu上&#xff0c;可以使用以下命令安装NFS客户端工具&#xff1a; shell复制代码 sudo apt-get install nfs-common 创建挂载点&#xff1a;在本地Ubuntu计算机上&#xff0c;…

机器学习(23)---Boosting tree(课堂笔记)

文章目录 一、知识记录二、题目2.1 题目12.2 题目22.3 题目三2.4 答案书写 一、知识记录 二、题目 2.1 题目1 2.2 题目2 2.3 题目三 T 4 T_4 T4​中 0.15 0.15 0.15 改为 − 0.16 -0.16 −0.16&#xff0c; − 0.22 -0.22 −0.22 改为 0.11 0.11 0.11。 2.4 答案书写

python 之计算矩阵乘法

文章目录 总的介绍例子 总的介绍 np.matmul 是NumPy库中的矩阵乘法函数&#xff0c;用于执行矩阵乘法操作。矩阵乘法是线性代数中的一种常见操作&#xff0c;用于将两个矩阵相乘以生成新的矩阵。在神经网络、机器学习和科学计算中&#xff0c;矩阵乘法经常用于变换和组合数据。…

点云cloudpoint生成octomap的OcTree的两种方法以及rviz可视化

第一种&#xff1a;在自己的项目中将点云通过ros的topic发布&#xff0c;用octomap_server订阅点云消息&#xff0c;在octomap_server中生成ocTree 再用rviz进行可视化。 创建工作空间&#xff0c;记得source mkdir temp_ocotmap_test/src cd temp_ocotmap_test catkin_make…

算法刷题-数组

算法刷题 209. 长度最小的子数组-二分或者滑动窗口 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl1, ..., numsr-1, numsr] &#xff0c;并返回其长度**。**如果不存在符合条件的子数…

进制转换(二进制、八进制、十进制、十六进制)

目录 一&#xff1a;十进制转换为二进制、八进制、十六进制 &#xff08;1&#xff09;整数转换 &#xff08;2&#xff09;小数转换 1&#xff09;十进制转二进制 2&#xff09;十进制转八进制 3&#xff09;十进制转十六进制 二&#xff1a;二进制、八进制、十六进制转…