詳解UnityWebRequest類

什么是UnityWebRequest類

UnityWebRequest?是 Unity 引擎中用于處理網絡請求的一個強大類,它可以讓你在 Unity 項目里方便地與網絡資源進行交互,像發送 HTTP 請求、下載文件等操作都能實現。下面會詳細介紹?UnityWebRequest?的相關內容。

UnityWebRequest中的常用操作

? ? ? ? //1.使用Get獲取文本或二進制數據
? ? ? ? //2.使用Get獲取紋理數據
? ? ? ? //3.使用Get獲取AB包數據
? ? ? ? //4.使用Post請求發送數據
? ? ? ? //5.使用Put請求上傳數據

Get操作

       #region 知識點三 Get獲取操作//1.獲取文本或2進制StartCoroutine(DownLoadText());//2.獲取紋理StartCoroutine(DownLoadImage());//3.獲取AB包StartCoroutine(DownLoadAB());#endregion }IEnumerator DownLoadText(){UnityWebRequest req = UnityWebRequest.Get("http://172.41.2.6/HTTP_Server/");//就會等待服務器端響應后 斷開連接后 再繼續執行后面的內容yield return req.SendWebRequest();//如果處理成功,結果就是成功枚舉if(req.result ==UnityWebRequest.Result.Success){//文本 字符串print(req.downloadHandler.text);//字節數組byte[] bytes = req.downloadHandler.data;}else{print("獲取失敗:" + req.result + req.error + req.responseCode);}}IEnumerator DownLoadImage(){UnityWebRequest req = new UnityWebRequest("http://172.41.2.6/HTTP_Server/測試圖片.png");yield return req.SendWebRequest();if(req.result ==UnityWebRequest.Result.Success ){//(req.downloadHandler as DownloadHandlerTexture).texture;//DownloadHandlerTexture.GetContent(req);//image.texture =(req.downloadHandler as DownloadHandlerTexture).texture;image.texture = DownloadHandlerTexture.GetContent(req);}else{print("獲取失敗" + req.error + req.result + req.responseCode);}}IEnumerator DownLoadAB(){UnityWebRequest req = UnityWebRequestAssetBundle.GetAssetBundle("http://172.41.2.6/HTTP_Server/lua");//yield return req.SendWebRequest();req.SendWebRequest();while(!req .isDone ){print(req.downloadProgress);print(req.downloadedBytes);yield return null;}if(req .result ==UnityWebRequest.Result.Success ){//AssetBundle ab=(req.downloadHandler as DownloadHandlerAssetBundle).assetBundle;AssetBundle ab = DownloadHandlerAssetBundle.GetContent(req);}elseprint("獲取失敗" + req.error + req.result + req.responseCode);}

Post和Put操作

上傳數據相關類

       #region 知識點一 上傳相關數據類//父接口//IMultipartFromSection//數據相關類都繼承該接口//我們可以用父類裝子類List<IMultipartFormSection> dataList = new List<IMultipartFormSection>();//子類數據//MutipartFromDataSection//1.二進制字節數組dataList.Add(new MultipartFormDataSection(Encoding.UTF8.GetBytes("23399ffs")));//2.字符串dataList.Add(new MultipartFormDataSection("sjfjgnafd"));//3.參數名、參數值(字節數組、字符串)、編碼類型、資源類型(常用)dataList.Add(new MultipartFormDataSection("Name", "DamnF", Encoding.UTF8, "application/..."));dataList.Add(new MultipartFormDataSection("msg", new byte[1024], "appl...."));//MultipartFromFileSection//1.字節數組dataList.Add(new MultipartFormFileSection(File.ReadAllBytes(Application.streamingAssetsPath + "/test.png")));//2.文件名、字節數組(常用)dataList.Add(new MultipartFormFileSection("上傳的文件.png", File.ReadAllBytes(Application.streamingAssetsPath + "/test.png")));//3.字符串數據、文件名(常用)dataList.Add(new MultipartFormFileSection("2r0402099", "text.txt"));//4.字符串數據、編碼格式、文件名(常用)dataList.Add(new MultipartFormFileSection("299ffjej3", Encoding.UTF8, "test.txt"));//5.表單名、字節數組、文件名、文件類型dataList.Add(new MultipartFormFileSection("file", new byte[1024], "test.txt", ""));//6.表單名、字符串數據、編碼格式、文件名dataList.Add(new MultipartFormFileSection("file", "dggt4hdsgg", Encoding .UTF8, ""));#endregion

Post和Put

       #region 知識點二 Post發送相關StartCoroutine(UpLoad());#endregion#region 知識點三 Put上傳相關//注意:Put請求類型不是所有的web服務器都認,必須要服務器處理該請求才能有響應#endregion }IEnumerator UpLoad(){//準備上傳的數據List<IMultipartFormSection> dataList = new List<IMultipartFormSection>();//鍵值對相關的 信息 字段數據dataList.Add(new MultipartFormDataSection("Name", "DamnF"));//PlayerMsg msg = new PlayerMsg();//dataList.Add(new MultipartFormDataSection("Msg", msg.Writing()));//添加一些上傳文件//傳2進制文件dataList.Add(new MultipartFormFileSection("TestTest124.png", File.ReadAllBytes(Application.streamingAssetsPath + "/test.png")));//傳文本文件dataList.Add(new MultipartFormFileSection("12444515", "Test123.txt"));UnityWebRequest req = UnityWebRequest.Post("http://172.41.2.6/HTTP_Server/",dataList);req.SendWebRequest();while (!req.isDone){print(req.uploadProgress);print(req.uploadedBytes);yield return null;}print(req.uploadProgress);print(req.uploadedBytes);if (req.result == UnityWebRequest.Result.Success){print("上傳成功");//req.downloadHandler.data;}elseprint("上傳失敗" + req.error + req.responseCode + req.result);}IEnumerator UpLoadPut(){UnityWebRequest req= UnityWebRequest.Put("http://172.41.2.6/HTTP_Server/", File.ReadAllBytes(Application.streamingAssetsPath + "/test.png"));yield return req.SendWebRequest();if(req.result ==UnityWebRequest.Result.Success ){print("上傳put成功");}else{}}

UnityWebRequest中的高級操作

       #region 知識點一 UnityWebRequest高級操作指什么//高級操作是指讓你按照規則來實現更多的數據獲取、上傳的功能#endregion#region 知識點二 UnityWebRequest中更多的內容//目前已學的內容//UnityWebRequest req = UnityWebRequest.Get("");//UnityWebRequest req = UnityWebRequestTexture.GetTexture("");//UnityWebRequest req = UnityWebRequestAssetBundle.GetAssetBundle("");//UnityWebRequest req = UnityWebRequest.Put();//UnityWebRequest req = UnityWebRequest.Post();//req.isDone//req.downloadProgress//req.downloadProgress //req.uploadedBytes//req.uploadProgress//req.SendWebRequest();//更多內容//1.構造函數UnityWebRequest req = new UnityWebRequest();//2.請求地址req.url = "服務器地址";//3.請求類型req.method = UnityWebRequest.kHttpVerbGET;//4.進度//req.downloadProgress//req.uploadProgress //5.超時設置//req.timeout=2000;//6.上傳、下載的字節數//req.uploadedBytes //req.downloadedBytes //7.重定向次數 設置為0表示不進行重定向 可以設置次數req.redirectLimit = 10;//8.狀態碼 結果 錯誤內容//req.result;//req.error;//req.responseCode;//9.下載、上傳處理對象//req.downloadHandler;//req.uploadHandler;#endregion #region 知識點三 自定義獲取數據DownloadHandler相關類//關鍵類://1.DownloadHandlerBuffer 用于簡單的數據存儲,得到對應的2進制數據//2.DownloadHandlerFile 用于下載文件并將文件保存到磁盤(內存占用少)//3.DownloasHandlerTexture 用于下載圖像//4.DownloadHandlerAssetBundle 用于提取AssetBundle//5.DownloadHandlerAudioClip 用于下載音頻文件//以上的類,其實是Unity幫我們實現好的,用于解析下載下來的數據的類//使用對應的類處理下載數據 它們就會在內部將下載好的數據處理為對應類型,方便我們使用//DownloadHandlerScript 是一個特殊的類 就本身而言 不會執行任何操作//但是此類可由用戶定義的類繼承。此類接收來自UnityWebRequest系統的回調//然后可以使用這些回調在數據從網絡到達時執行完全自定義的數據處理StartCoroutine(DownLoadTex());StartCoroutine(DownLoadAB());StartCoroutine(DownLoadAudioClip());#endregion}IEnumerator DownLoadTex(){UnityWebRequest req = new UnityWebRequest("http://172.41.2.6/HTTP_Server/測試圖片.png", UnityWebRequest.kHttpVerbGET);//req.method = UnityWebRequest.kHttpVerbGET;//1.DownloadHandlerBufferDownloadHandlerBuffer bufferHandler = new DownloadHandlerBuffer();req.downloadHandler = bufferHandler;//2.DownloadHandlerFilereq.downloadHandler = new DownloadHandlerFile(Application.persistentDataPath + "/downloadfile.png");//3.DownloadHandlerTextureDownloadHandlerTexture handlerTexture = new DownloadHandlerTexture();req.downloadHandler = handlerTexture;yield return req.SendWebRequest();if(req.result ==UnityWebRequest.Result.Success ){//獲取字節數組//bufferHandler.data}else{print("獲取數據失敗" + req.result + req.error + req.responseCode);}}IEnumerator DownLoadAB(){UnityWebRequest req = new UnityWebRequest("http://172.41.2.6/HTTP_Server/lua", UnityWebRequest.kHttpVerbGET);//第二個參數,需要已知校檢碼 才能進行比較 檢查完整性 如果不知道的話 只能傳0 不進行完整性檢查//所以一般 只有進行AB包熱更新時 服務器發送了 對應的 文件列表中 包含了 驗證碼才能進行檢查DownloadHandlerAssetBundle downloadHandlerAB = new DownloadHandlerAssetBundle(req.url, 0);req.downloadHandler = downloadHandlerAB;yield return req.SendWebRequest();if (req.result == UnityWebRequest.Result.Success){AssetBundle ab = downloadHandlerAB.assetBundle;print(ab.name);}else{print("獲取數據失敗" + req.result + req.error + req.responseCode);}}IEnumerator DownLoadAudioClip(){UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("http://172.41.2.6/HTTP_Server/音效文件.mp3",AudioType.MPEG);yield return req.SendWebRequest();if (req.result == UnityWebRequest.Result.Success){AudioClip a= DownloadHandlerAudioClip .GetContent(req);}else{print("獲取數據失敗" + req.result + req.error + req.responseCode);}}IEnumerator DownLoadCustomHandler(){UnityWebRequest req = new UnityWebRequest("http://172.41.2.6/HTTP_Server/測試圖片.png", UnityWebRequest.kHttpVerbGET);req.downloadHandler = new CustomDownLoadFileHandler(Application.persistentDataPath + "/CustomHandler.png");yield return req.SendWebRequest();if (req.result == UnityWebRequest.Result.Success){print("存儲本地成功");}else{print("獲取數據失敗" + req.result + req.error + req.responseCode);}}

自定義獲取數據處理

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;public class DownLoadHanderMsg :DownloadHandlerScript
{private BaseMsg msg;private int index = 0;private byte[] cacheBytes;public DownLoadHanderMsg ():base(){}public T GetMsg<T>()where T:BaseMsg{return msg as T;}protected override byte[] GetData(){return base.GetData();}protected override void ReceiveContentLengthHeader(ulong contentLength){base.ReceiveContentLengthHeader(contentLength);}protected override bool ReceiveData(byte[] data, int dataLength){data.CopyTo(cacheBytes, dataLength);index += dataLength;return true;}protected override void CompleteContent(){index = 0;int msgID = BitConverter.ToInt32(cacheBytes,index);index += 4;int msgLength = BitConverter.ToInt32(cacheBytes, index);index += 4;switch (msgID){case 1001:msg = new PlayerMsg();msg.Reading(cacheBytes, index);break;}if (msg == null){Debug.Log("對應ID" + msgID + "沒有處理");}elseDebug.Log("消息處理完畢");}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;public class Lesson34_E : MonoBehaviour
{// Start is called before the first frame updatevoid Start(){}IEnumerator GetMsg(){UnityWebRequest req = new UnityWebRequest("Web服務器地址", UnityWebRequest.kHttpVerbPOST);DownLoadHanderMsg  handlerMsg= new DownLoadHanderMsg();req.downloadHandler = handlerMsg;yield return req.SendWebRequest();if(req.result ==UnityWebRequest.Result.Success ){PlayerMsg msg = handlerMsg.GetMsg<PlayerMsg>();//使用消息對象,來進行邏輯處理}}// Update is called once per framevoid Update(){}
}

UnityWebRequest高級操作--上傳數據

using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;public class Lesson35 : MonoBehaviour
{// Start is called before the first frame updatevoid Start(){#region UnityWebRequest高級操作--上傳數據//1.UploadHandlerRaw--用于上傳字節數組//2.UploadHandlerFile--用于上傳文件//其中重要的變量是//contentType 內容類型,如果不設置,模式是application/octet-stream 2進制流的形式//以上部分作為了解,實際開發并不常用#endregion}IEnumerator UpLoad(){UnityWebRequest req = new UnityWebRequest("http://172.41.2.6/HTTP_Server/", UnityWebRequest.kHttpVerbPOST);//1.UploadHandlerRaw--用于上傳字節數組//byte[] bytes = Encoding.UTF8.GetBytes("23fe33h3h3h");//req.uploadHandler = new UploadHandlerRaw(bytes);req.uploadHandler.contentType = "類型/細分類型";//2.UploadHandlerFile--用于上傳文件req.uploadHandler = new UploadHandlerFile(Application.streamingAssetsPath + "/test.png");yield return req.SendWebRequest();print(req.result);}// Update is called once per framevoid Update(){}
}

將UnityWebRequest中的操作封裝到WWWMgr模塊中

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;public class WWWMgr : MonoBehaviour
{private static WWWMgr instance = new WWWMgr();public static WWWMgr Instance => instance;private string HTTP_SERVER_PATH = "http://172.41.2.6/HTTP_Server/";private void Awake(){instance = this;DontDestroyOnLoad(this.gameObject);}public void LoadRes<T>(string path, UnityAction<T> action) where T : class{StartCoroutine(LoadResAsync<T>(path, action));}private IEnumerator LoadResAsync<T>(string path, UnityAction<T> action) where T : class{WWW www = new WWW(path);yield return www;if (www.error == null){//根據T泛型的類型 決定使用哪種類型的資源 傳遞給外部if (typeof(T) == typeof(AssetBundle)){action?.Invoke(www.assetBundle as T);}else if (typeof(T) == typeof(Texture)){action?.Invoke(www.texture as T);}else if (typeof(T) == typeof(AudioClip)){action?.Invoke(www.GetAudioClip() as T);}else if (typeof(T) == typeof(string)){action?.Invoke(www.text as T);}else if (typeof(T) == typeof(byte[])){action?.Invoke(www.bytes as T);}}else{Debug.LogError("加載資源出錯了" + www.error);}}public void UnityWebRequestLoad<T>(string path,UnityAction <T>action,string localPath="",AudioType type=AudioType.MPEG )where T:class {StartCoroutine(UnityWebRequestLoadAsync<T>(path, action, localPath, type));}private IEnumerator UnityWebRequestLoadAsync<T>(string path, UnityAction<T> action, string localPath = "", AudioType type = AudioType.MPEG) where T:class {UnityWebRequest req = new UnityWebRequest(path, UnityWebRequest.kHttpVerbGET);if (typeof(T) == typeof(byte[]))req.downloadHandler = new DownloadHandlerBuffer();else if (typeof(T) == typeof(Texture))req.downloadHandler = new DownloadHandlerTexture();else if (typeof(T) == typeof(AssetBundle))req.downloadHandler = new DownloadHandlerAssetBundle(req.url, 0);else if (typeof(T) == typeof(object))req.downloadHandler = new DownloadHandlerFile(localPath);else if (typeof(T) == typeof(AudioClip))req = UnityWebRequestMultimedia.GetAudioClip(path, type);else //如果出現沒有的類型 就不用繼續執行{Debug.LogWarning("未知類型" + typeof(T));yield break;}yield return req.SendWebRequest();if(req.result ==UnityWebRequest.Result.Success ){if (typeof(T) == typeof(byte[]))action?.Invoke(req.downloadHandler.data as T);else if (typeof(T) == typeof(Texture))//action?.Invoke((req.downloadHandler as DownloadHandlerTexture).texture as T);action?.Invoke(DownloadHandlerTexture.GetContent(req) as T);else if (typeof(T) == typeof(AssetBundle))action?.Invoke((req.downloadHandler as DownloadHandlerAssetBundle).assetBundle as T);else if (typeof(T) == typeof(object))action?.Invoke(null);else if (typeof(T) == typeof(AudioClip))action?.Invoke(DownloadHandlerAudioClip.GetContent(req) as T);}else{Debug.LogWarning("獲取數據失敗" + req.result + req.error + req.responseCode);}}public void SendMsg<T>(BaseMsg msg,UnityAction<T>action)where T:BaseMsg {StartCoroutine(SendMsgAsync<T>(msg, action));}private IEnumerator SendMsgAsync<T>(BaseMsg msg,UnityAction <T>action)where T:BaseMsg {//消息發送WWWForm data = new WWWForm();//準備要發送的消息數據data.AddBinaryData("Msg", msg.Writing());WWW www = new WWW(HTTP_SERVER_PATH, data);//我們也可以直接傳遞 2進制字節數組 只要和后端制定好規則 怎么傳都是可以的//WWW www = new WWW(HTTP_SERVER_PATH, msg.Writing());//異步等待 發送結束 才會繼續執行后面的代碼yield return www;//發送完畢后 收到響應//認為后端發回來的內容也是一個繼承自BaseMsg類的字節數組對象if(www.error ==null){//先解析 ID和消息長度int index = 0;int msgID = BitConverter.ToInt32(www.bytes, index);index += 4;int msgLength = BitConverter.ToInt32(www.bytes, index);index += 4;//反序列化 BaseMsgBaseMsg baseMsg = null;switch (msgID){case 1001:baseMsg = new PlayerMsg();baseMsg.Reading(www.bytes, index);break;}if (baseMsg != null)action?.Invoke(baseMsg as T);elseDebug.LogError("發消息出現問題" + www.error);}}public void UpLoadFile(string fileName,string localName,UnityAction<UnityWebRequest .Result> action){StartCoroutine(UpLoadFileAsync(fileName, localName, action));}private IEnumerator UpLoadFileAsync(string fileName,string localName,UnityAction<UnityWebRequest .Result> action){List<IMultipartFormSection> dataList = new List<IMultipartFormSection>();dataList.Add(new MultipartFormDataSection(fileName, File.ReadAllBytes(localName)));UnityWebRequest req = UnityWebRequest.Post(HTTP_SERVER_PATH, dataList);yield return req.SendWebRequest();action?.Invoke(req.result);if (req.result != UnityWebRequest.Result.Success){print("上傳失敗" + req.error + req.responseCode + req.result);}}}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/80908.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/80908.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/80908.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

UE5 在旋轉A的基礎上執行旋轉B

用徑向slider實現模型旋轉時&#xff0c;得到的結果與ue編輯器里面的結果有很大出入。 問題應該是 兩個FRotator&#xff08;0&#xff0c;10&#xff0c;0&#xff09;和&#xff08;10&#xff0c;20&#xff0c;30&#xff09;&#xff0c; 兩個FRotator的加法結果為&…

4.2 Prompt工程與任務建模:高效提示詞設計與任務拆解方法

提示詞工程&#xff08;Prompt Engineering&#xff09;和任務建模&#xff08;Task Modeling&#xff09;已成為構建高效智能代理&#xff08;Agent&#xff09;系統的核心技術。提示詞工程通過精心設計的自然語言提示詞&#xff08;Prompts&#xff09;&#xff0c;引導大型語…

MySQL 索引的最左前綴匹配原則是什么?

MySQL 索引的最左前綴匹配原則詳解 最左前綴匹配原則&#xff08;Leftmost Prefix Principle&#xff09;是 MySQL 復合索引&#xff08;聯合索引&#xff09;查詢優化中的核心規則&#xff0c;理解這一原則對于高效使用索引至關重要。 核心概念 定義&#xff1a;當查詢條件…

SQL命令

一、控制臺中查詢命令 默認端口號&#xff1a;3306 查看服務器版本: mysql –version 啟動MySQL服務&#xff1a;net start mysql 登錄數據庫&#xff1a;mysql -u root -p 查看當前系統下的數據庫&#xff1a;show databases&#xff1b; 創建數據庫&#xff1a;create…

新增 29 個專業,科技成為關鍵賽道!

近日&#xff0c;教育部正式發布《普通高等學校本科專業目錄&#xff08;2025年&#xff09;》&#xff0c;新增 29 個本科專業&#xff0c;包括區域國別學、碳中和科學與工程、海洋科學與技術、健康與醫療保障、智能分子工程、醫療器械與裝備工程、時空信息工程、國際郵輪管理…

零基礎上手Python數據分析 (23):NumPy 數值計算基礎 - 數據分析的加速“引擎”

寫在前面 —— 超越原生 Python 列表,解鎖高性能數值計算,深入理解 Pandas 的底層依賴 在前面一系列關于 Pandas 的學習中,我們已經領略了其在數據處理和分析方面的強大威力。我們學會了使用 DataFrame 和 Series 來高效地操作表格數據。但是,你是否好奇,Pandas 為何能夠…

Android 13.0 MTK Camera2 設置默認拍照尺寸功能實現

Android 13.0 MTK Camera2 設置默認拍照尺寸功能實現 文章目錄 需求&#xff1a;參考資料架構圖了解Camera相關專欄零散知識了解部分相機源碼參考&#xff0c;學習API使用&#xff0c;梳理流程&#xff0c;偏應用層Camera2 系統相關 修改文件-修改方案修改文件&#xff1a;修改…

HarmonyOS 框架基礎知識

參考文檔&#xff1a;HarmonyOS開發者文檔 第三方庫&#xff1a;OpenHarmony三方庫中心倉 基礎特性 Entry&#xff1a;關鍵裝飾器 Components&#xff1a;組件 特性EntryComponent??作用范圍僅用于頁面入口可定義任意可復用組件??數量限制??每個頁面有且僅有一個無數量…

前端分頁與瀑布流最佳實踐筆記 - React Antd 版

前端分頁與瀑布流最佳實踐筆記 - React Antd 版 1. 分頁與瀑布流對比 分頁&#xff08;Pagination&#xff09;瀑布流&#xff08;Infinite Scroll&#xff09;展示方式按頁分批加載&#xff0c;有明確頁碼控件滾動到底部時自動加載更多內容&#xff0c;無明顯分頁用戶控制用…

Linux網絡編程:TCP多進程/多線程并發服務器詳解

Linux網絡編程&#xff1a;TCP多進程/多線程并發服務器詳解 TCP并發服務器概述 在Linux網絡編程中&#xff0c;TCP服務器主要有三種并發模型&#xff1a; 多進程模型&#xff1a;為每個客戶端連接創建新進程多線程模型&#xff1a;為每個客戶端連接創建新線程I/O多路復用&am…

詳解springcloudalibaba采用prometheus+grafana實現服務監控

文章目錄 1.官網下載安裝 prometheus和grafana1.promethus2.grafana 2. 搭建springcloudalibaba集成prometheus、grafana1. 引入依賴,springboot3.2之后引入如下2. 在yml文件配置監控端點暴露配置3. 在當前啟動的應用代碼中添加&#xff0c;在prometheus顯示的時候附加當前應用…

數據分析1

一、常用數據處理模塊Numpy Numpy常用于高性能計算&#xff0c;在機器學習常常作為傳遞數據的容器。提供了兩種基本對象&#xff1a;ndarray、ufunc。 ndarray具有矢量算術運算和復雜廣播能力的快速且節省空間的多維數組。 ufunc提供了對數組快速運算的標準數學函數。 ndar…

DeepSeek智能時空數據分析(六):大模型NL2SQL繪制城市之間連線

序言&#xff1a;時空數據分析很有用&#xff0c;但是GIS/時空數據庫技術門檻太高 時空數據分析在優化業務運營中至關重要&#xff0c;然而&#xff0c;三大挑戰仍制約其發展&#xff1a;技術門檻高&#xff0c;需融合GIS理論、SQL開發與時空數據庫等多領域知識&#xff1b;空…

2023ICPC合肥題解

文章目錄 F. Colorful Balloons(簽到)E. Matrix Distances(思維小結論)J. Takeout Delivering(最短路)G. Streak Manipulation(二分dp)C. Cyclic Substrings(回文自動機) 題目鏈接 F. Colorful Balloons(簽到) int n;cin>>n;for(int i1;i<n;i) cin>>s[i];map<…

數字技術驅動下教育生態重構:從信息化整合到數字化轉型的路徑探究

一、引言 &#xff08;一&#xff09;研究背景與問題提出 在當今時代&#xff0c;數字技術正以前所未有的速度和深度滲透到社會的各個領域&#xff0c;教育領域也不例外。從早期的教育信息化整合到如今的數字化轉型&#xff0c;教育系統正經歷著一場深刻的范式變革。 回顧教…

terraform 動態塊(Dynamic Blocks)詳解與實踐

在 Terraform 中&#xff0c;動態塊&#xff08;Dynamic Blocks&#xff09; 是一種強大的機制&#xff0c;允許你根據變量或表達式動態生成配置塊&#xff0c;避免重復編寫相似的代碼。這在處理需要重復定義的結構&#xff08;如資源參數、嵌套配置&#xff09;時特別有用。以…

Unity3D引擎框架及用戶接口調用方式相關分析及匯總

分析目的 目前外網3D手游絕大部基于Unity3D引擎進行開發,Unity3D引擎屬于商業引擎,引擎整理框架的運行機制較為神秘,本文介紹Unity引擎框架、對象組織方式、用戶接口與引擎交互方式等原理,通過本文的分析和介紹可了解Unity3D框架中大致執行原理。 實現原理 Unity引擎作為…

react-09React生命周期

1.react生命周期&#xff08;舊版&#xff09; 1.1react初始掛載時的生命周期 1:構造器-constructor // 構造器constructor(props) {console.log(1:構造器-constructor);super(props)// 初始化狀態this.state {count: 0}} 2:組件將要掛載-componentWillMount // 組件將要掛載…

【NVM】管理不同版本的node.js

目錄 一、下載nvm 二、安裝nvm 三、驗證安裝 四、配置下載鏡像 五、使用NVM 前言&#xff1a;不同的node.js版本會讓你在使用過程很費勁&#xff0c;nvm是一個node版本管理工具&#xff0c;通過它可以安裝多種node版本并且可以快速、簡單的切換node版本。 一、下載nvm htt…

八大排序——冒泡排序/歸并排序

八大排序——冒泡排序/歸并排序 一、冒泡排序 1.1 冒泡排序 1.2 冒泡排序優化 二、歸并排序 1.1 歸并排序&#xff08;遞歸&#xff09; 1.2 遞歸排序&#xff08;非遞歸&#xff09; 一、冒泡排序 1.1 冒泡排序 比較相鄰的元素。如果第一個比第二個大&#xff0c;就交換…