P7 QT項目----會學天氣預報(完結)

7.8 QMap

Qt 中,如果你想要將 JSON 數據解析到一個 QMap 中,你可以遍歷 JSON 對象的所有鍵值對,并將它們添加到 QMap 里。這個方法特別適合于當你的 JSON 對象是一個簡單的鍵值對集合時。以下是一個如何實現這一點的示例。
示例:將 JSON 數據解析到 QMap
假設你有以下 JSON 數據:
json
{
????????"name" : "John Doe" ,
????????"age" : "30" ,
????????"email" : "john.doe@example.com"
}
以下是如何將這些數據解析到 QMap<QString, QString> 中的步驟:
#include <QJsonDocument>
#include <QJsonObject>
#include <QMap>
#include <QDebug>
void parseJsonToMap() {
// JSON字符串
QString jsonString = R"(
{
????????"name": "John Doe",
????????"age": "30",
????????"email": "john.doe@example.com"
}
)";
// 將JSON字符串轉換為QJsonDocument
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonString.toUtf8());
// 準備一個QMap來存儲解析的數據
QMap<QString, QString> dataMap;
// 解析JSON對象并填充QMap
if (!jsonDoc.isNull() && jsonDoc.isObject()) {
????????QJsonObject jsonObj = jsonDoc.object();
????????for (auto key : jsonObj.keys()) {
????????????????dataMap[key] = jsonObj.value(key).toString();
????????}
} else {
????????qDebug() << "Invalid JSON...";
}
// 打印QMap內容
for (auto key : dataMap.keys()) {
????????qDebug() << key << ":" << dataMap[key];
????????}
}
int main() {
????????parseJsonToMap();
????????return 0;
}
1. JSON 字符串創建 QJsonDocument :使用 QJsonDocument::fromJson 來解析 JSON 字符串。
2. 創建 QMap :定義一個 QMap<QString, QString> 來存儲鍵值對。
3. 遍歷 JSON 對象 :使用 keys() 方法獲取所有鍵,然后遍歷這些鍵,將對應的值添加到 QMap 中。
4. 打印 QMap 內容 :遍歷 QMap 并打印鍵值對。
這個示例展示了如何將 JSON 對象的鍵值對解析到 QMap 中。這種方法適用于鍵值對類型的簡單 JSON 對象。對于更復雜的JSON 結構,可能需要更詳細的解析邏輯
#include "widget.h"
#include "ui_widget.h"
 
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>
#include <QMessageBox>
#include <QJsonDocument>
#include <QByteArray>
#include <QFile>
#include <QJsonObject>
#include <QJsonArray>
#include <QPainter>
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
 
    //窗體無狀態欄
    //setWindowFlag(Qt::FramelessWindowHint);
 
    //界面跟隨
    this->setLayout(ui->verticalLayout);
 
    //QMenu菜單組件
    menuQuit = new QMenu(this);
    //設置菜單項文字顏色
    menuQuit->setStyleSheet("QMenu::item{color : red}");
    //用戶點擊菜單項并點擊后回調函數,推出程序
    connect(menuQuit,&QMenu::triggered,[=](){
        this->close();
    });
 
    //由QNetworkAccessManager發起get請求
    mannager = new  QNetworkAccessManager(this);
    //QNetworkReply * get(const QNetworkRequest &request)  QNetworkRequest(const QUrl &url = QUrl())
    //strurl = "http://gfeljm.tianqiapi.com/api?unescape=1&version=v63&appid=76269866&appsecret=VRtxb7NZ";
    strurl = "http://gfeljm.tianqiapi.com/api?unescape=1&version=v9&appid=76269866&appsecret=VRtxb7NZ";
    QUrl urlNetId(strurl);
    //指定請求url地址
    QNetworkRequest request(urlNetId);
    reply = mannager->get(request);
    //QNetworkRequest網絡請求后進行數據讀取
    connect(mannager,&QNetworkAccessManager::finished,this,&Widget::readHTTPSerial);
 
    mWeekList << ui->label_day0 << ui->label_day1
              << ui->label_day2 << ui->label_day3
              << ui->label_day4 << ui->label_day5;
 
    mDateList << ui->label_date0 << ui->label_date1
              << ui->label_date2 << ui->label_date3
              << ui->label_date4 << ui->label_date5;
 
    mIconList <<ui->label_weaIcon0 <<ui->label_weaIcon1
             <<ui->label_weaIcon2 <<ui->label_weaIcon3
            <<ui->label_weaIcon4 <<ui->label_weaIcon5;
 
    mWeaTypeList << ui->label_weaType0 << ui->label_weaType1
                 << ui->label_weaType2 << ui->label_weaType3
                 << ui->label_weaType4 << ui->label_weaType5;
 
    mAirqList << ui->label_Airq0 << ui->label_Airq1
              << ui->label_Airq2 << ui->label_Airq3
              << ui->label_Airq4 << ui->label_Airq5;
 
    mFxList << ui->label_Fx0 << ui->label_Fx1
            << ui->label_Fx2 << ui->label_Fx3
            << ui->label_Fx4 << ui->label_Fx5;
 
    mFlList << ui->label_Fl0 << ui->label_Fl1
            << ui->label_Fl2 << ui->label_Fl3
            << ui->label_Fl4 << ui->label_Fl5;
 
    //根據天氣,設置icon的路徑
    mTypeMap.insert("暴雪",":/res/type/BaoXue.png");
    mTypeMap.insert("暴雨",":/res/type/BaoYu. png");
    mTypeMap.insert("暴雨到大暴雨",":/res/type/BaoYuDaoDaBaoYu.png");
    mTypeMap.insert("大暴雨",":/res/type/DaBaoYu.png");
    mTypeMap.insert("大暴雨到特大暴雨",":/res/type/DaBaoYuDaoTeDaBaoYu.png");
    mTypeMap.insert("大到暴雪",":/res/type/DaDaoBaoXue.png");
    mTypeMap.insert("大雪",":/res/type/DaXue.png");
    mTypeMap.insert("大雨",":/res/type/DaYu.png");
    mTypeMap.insert("凍雨",":/res/type/DongYu.png");
    mTypeMap.insert("多云",":/res/type/DuoYun.png");
    mTypeMap.insert("浮沉",":/res/type/FuChen.png");
    mTypeMap.insert("雷陣雨",":/res/type/LeiZhenYu.png");
    mTypeMap.insert("雷陣雨伴有冰雹",":/res/type/LeiZhenYuBanYouBingBao.png");
    mTypeMap.insert("霾",":/res/type/Mai.png");
    mTypeMap.insert("強沙塵暴",":/res/type/QiangShaChenBao.png");
    mTypeMap.insert("晴",":/res/type/Qing.png");
    mTypeMap.insert("沙塵暴",":/res/type/ShaChenBao.png");
    mTypeMap.insert("特大暴雨",":/res/type/TeDaBaoYu.png");
    mTypeMap.insert("undefined",":/res/type/undefined.png");
    mTypeMap.insert("霧",":/res/type/Wu.png");
    mTypeMap.insert("小到中雪",":/res/type/XiaoDaoZhongXue.png");
    mTypeMap.insert("小到中雨",":/res/type/XiaoDaoZhongYu.png");
    mTypeMap.insert("小雪",":/res/type/XiaoXue.png");
    mTypeMap.insert("小雨",":/res/type/XiaoYu.png");
    mTypeMap.insert("雪",":/res/type/Xue.png");
    mTypeMap.insert("揚沙",":/res/type/YangSha.png");
    mTypeMap.insert("陰",":/res/type/Yin.png");
    mTypeMap.insert("雨",":/res/type/Yu.png");
    mTypeMap.insert("雨夾雪",":/res/type/YuJiaXue.png");
    mTypeMap.insert("陣雪",":/res/type/ZhenXue.png");
    mTypeMap.insert("陣雨",":/res/type/ZhenYu.png");
    mTypeMap.insert("中到大雪",":/res/type/ZhongDaoDaXue.png");
    mTypeMap.insert("中到大雨",":/res/type/ZhongDaoDaYu.png");
    mTypeMap.insert("中雪",":/res/type/ZhongXue.png");
    mTypeMap.insert("中雨",":/res/type/ZhongYu.png");
 
    ui->widget_07->installEventFilter(this);
    ui->widget_08->installEventFilter(this);
}
 
Widget::~Widget()
{
    delete ui;
}
 
/* 解析當天天氣的Json文件 */
//void Widget::PaserWeatherFromJson(QByteArray rawData)
//{
//    //獲取天氣,QByteArray轉為QJsonDocument
//    QJsonDocument jsonDoc = QJsonDocument::fromJson(rawData);
//    //文本不為空且是鍵值表,QJsonDocument轉為QJsonObject
//    if(!jsonDoc.isNull() && jsonDoc.isObject()){
//        QJsonObject jsonObj = jsonDoc.object();
//        //日期
//        ui->label_date0102->setText(jsonObj["date"].toString() +
//                "  " + jsonObj["week"].toString());
//        //城市
//        ui->label_city02->setText(jsonObj["city"].toString());
//        //溫度
//        ui->label_temp02->setText(jsonObj["tem"].toString() + "℃");
//        //天氣
//        ui->label_weather02->setText(jsonObj["wea"].toString());
//        //天氣圖標
//        ui->label_icon02->setPixmap(mTypeMap[jsonObj["wea"].toString()]);
//        //溫度范圍
//        ui->label_weatherdata02->setText(jsonObj["tem2"].toString() +
//                "~" + jsonObj["tem1"].toString() + "℃");
//        //感冒指數
//        ui->label_text0301->setText(jsonObj["air_tips"].toString());
//        //風向
//        ui->label_FX->setText(jsonObj["win"].toString());
//        //風速
//        ui->label_FXdata->setText(jsonObj["win_speed"].toString());
//        //濕度
//        ui->label_SDdata->setText(jsonObj["humidity"].toString());
//        //PM值
//        ui->label_PMdata->setText(jsonObj["air_pm25"].toString());
//        //空氣質量
//        ui->label_airQdata->setText(jsonObj["air_level"].toString());
//    }
//}
 
/* 解析7天天氣的Json文件 */
void Widget::PaserWeatherFromJsonNew(QByteArray rawData)
{
    QJsonDocument jsonDoc = QJsonDocument::fromJson(rawData);
    if(!jsonDoc.isNull() && jsonDoc.isObject()){
        QJsonObject jsonRoot = jsonDoc.object();
        days[0].mCity = jsonRoot["city"].toString();
        days[0].mPM25 = jsonRoot["aqi"].toObject()["pm25"].toString();
        qDebug() << days[0].mPM25;
 
        if(jsonRoot.contains("data") && jsonRoot["data"].isArray()){
            QJsonArray dataArray = jsonRoot["data"].toArray();
            for (int i = 0; i < dataArray.size(); i++) {
                QJsonObject jsonObj = dataArray[i].toObject();
                days[i].mDate = jsonObj["date"].toString();
                days[i].mWeek = jsonObj["week"].toString();
                days[i].mTem = jsonObj["tem"].toString();
                days[i].mWea = jsonObj["wea"].toString();
                days[i].mTemLow = jsonObj["tem2"].toString();
                days[i].mTemHigh = jsonObj["tem1"].toString();
                days[i].mTips = jsonObj["air_tips"].toString();
                days[i].mFx = jsonObj["win"].toArray()[0].toString();
                days[i].mFl = jsonObj["win_speed"].toString();
                days[i].mHumidity = jsonObj["humidity"].toString();
                days[i].mAirq = jsonObj["air_level"].toString();
            }
        }
    }
    updateUI();
}
 
void Widget::updateUI()
{
    QPixmap pixmap;
 
    //日期
    ui->label_date0102->setText(days[0].mDate + days[0].mWeek);
    //城市
    ui->label_city02->setText(days[0].mCity);
    //溫度
    ui->label_temp02->setText(days[0].mTem + "℃");
    //天氣
    ui->label_weather02->setText(days[0].mWea);
    //天氣圖標
    ui->label_icon02->setPixmap(mTypeMap[days[0].mWea]);
    //溫度范圍
    ui->label_weatherdata02->setText(days[0].mTemLow +
            " ~ " + days[0].mTemHigh + "℃");
    //感冒指數
    ui->label_text0301->setText(days[0].mTips);
    //風向
    ui->label_FX->setText(days[0].mFx);
    //風速
    ui->label_FXdata->setText(days[0].mFl);
    //濕度
    ui->label_SDdata->setText(days[0].mHumidity);
    //PM值
    ui->label_PMdata->setText(days[0].mPM25);
    //空氣質量
    ui->label_airQdata->setText(days[0].mAirq);
 
    //遍歷ui界面的label
    for (int i = 0; i < 6; i++) {
        //設置日期
        mWeekList[i]->setText(days[i].mWeek);
        mWeekList[0]->setText("今天");
        mWeekList[1]->setText("明天");
        mWeekList[2]->setText("后天");
 
        //設置日期
        QStringList dayList = days[i].mDate.split("-");
        //只顯示月日,不顯示年,用-分隔開
        mDateList[i]->setText(dayList.at(1)+"-"+dayList.at(2));
 
        //設置圖像
        int indexpixMAp = days[i].mWea.indexOf("轉");
        //顯示轉的左邊相符天氣的圖片
        if(indexpixMAp != -1){
            pixmap = mTypeMap[days[i].mWea.left(indexpixMAp)];
        }
        else {
            pixmap = mTypeMap[days[i].mWea];
        }
        //設置圖片的樣式scaled
        pixmap = pixmap.scaled(mIconList[i]->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation);
        //設置圖片的寬度與高度
        mIconList[i]->setMaximumWidth(ui->widget_05->width()/6.5);
        mIconList[i]->setMaximumHeight(50);
        mIconList[i]->setPixmap(pixmap);
 
        //設置天氣類型
        mWeaTypeList[i]->setText(days[i].mWea);
 
        //設置天氣質量
        QString daysAirq = days[i].mAirq;
        mAirqList[i]->setText(daysAirq);
        if(daysAirq == "優"){
            //設置背景
              mAirqList[i]->setStyleSheet("background-color: rgb(86, 223, 48);color: rgb(255, 255, 255);border-radius:7px;");
        }
        if(daysAirq == "良"){
              mAirqList[i]->setStyleSheet("background-color: rgb(255, 184, 70);color: rgb(255, 255, 255);border-radius:7px;");
        }
        if(daysAirq == "輕度"){
              mAirqList[i]->setStyleSheet("background-color: rgb(245, 223, 48);color: rgb(255, 255, 255);border-radius:7px;");
        }
        if(daysAirq == "中度"){
              mAirqList[i]->setStyleSheet("background-color: rgb(245, 82, 84);color: rgb(255, 255, 255);border-radius:7px;");
        }
        if(daysAirq == "中度"){
              mAirqList[i]->setStyleSheet("background-color: rgb(255, 0, 0);color: rgb(255, 255, 255);border-radius:7px;");
        }
 
        //設置風向
        mFxList[i]->setText(days[i].mFx);
 
        //設置風力
        int indexFl = days[i].mFl.indexOf("轉");
        //顯示轉的左邊相符天氣的風力
        if(indexFl != -1){
            mFlList[i]->setText(days[i].mFl.left(indexFl));
        }
        else {
            mFlList[i]->setText(days[i].mFl);
        }
    }
 
    //更新顯示
    update();
}
 
 
 
/* 獲取天氣的Json文件 */
void Widget::readHTTPSerial(QNetworkReply *reply)
{
    //http協議的狀態碼
    int state_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    //無錯誤卻狀態碼等于200,獲取天氣的數據
    if(reply->error() == QNetworkReply::NoError && state_code == 200){
        //大多數服務器返回的字符編碼格式是utf-8
        QByteArray data = reply->readAll();
        //PaserWeatherFromJson(data);
        PaserWeatherFromJsonNew(data);
        //調試
        //qDebug() << QString::fromUtf8( data);
    }
    else {
        //生成一個提示窗口
        QMessageBox msgBox;
        msgBox.setWindowTitle("錯誤");
        msgBox.setText("網絡連接錯誤");
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.exec();
        //調試
        reply->errorString();
    }
}
 
/* 鼠標按下觸發事件 */
void Widget::mousePressEvent(QMouseEvent *event)
{
    //鼠標右鍵按下
    if(event->button() == Qt::RightButton){
        //qDebug() << "Rigght button clicked!";
        //顯示推出窗口
        menuQuit->addAction(QIcon(":/res/close.png"),"退出");
        //窗口出現在鼠標的位置
        menuQuit->exec(QCursor::pos());
    }
 
    //鼠標左鍵按下
    if(event->button() == Qt::LeftButton){
        //qDebug() << "Left button clicked!";
        //獲取鼠標的位置,界面左上角的位置
        //qDebug() << event->globalPos() << this->pos();
        //偏移量:鼠標位置與界面左上角的位置的差
        mOffset = event->globalPos() - this->pos();
    }
}
 
/* 鼠標拖動移動界面 */
void Widget::mouseMoveEvent(QMouseEvent *event)
{
    //減去偏移量會更濕滑,不然鼠標會跑到界面左上角的位置
    this->move(event->globalPos() - mOffset);
}
 
bool Widget::eventFilter(QObject *watched, QEvent *event)
{
    if(watched == ui->widget_07 && event->type() == QEvent::Paint){
        drawTempHigh();
    }
 
    if(watched == ui->widget_08 && event->type() == QEvent::Paint){
        drawTempLow();
    }
    return QWidget::eventFilter(watched,event);
}
 
void Widget::drawTempHigh()
{
    QPainter painter(ui->widget_07);
    painter.setRenderHint(QPainter::Antialiasing,true);
    painter.setBrush(QBrush(QColor(255, 126, 52)));
    painter.setPen(QColor(255, 126, 52));
 
    int t_ave;
    int sum = 0;
    int offset = 0;
    int middle = ui->widget_07->height()/2;
    for (int i = 0; i < 6; i++) {
         sum += days[i].mTemHigh.toUInt();
    }
    t_ave = sum / 6;
 
    //定義出6個點
    QPoint points[6];
    for (int i = 0; i < 6; i++) {
        points[i].setX(mAirqList[i]->x() + mAirqList[i]->width()/2);
        offset = (days[i].mTemHigh.toInt() - t_ave)*3;
        points[i].setY(middle - offset);
        //畫點
        painter.drawEllipse(QPoint(points[i]),3,3);
        //畫實際溫度
        painter.drawText(points[i].x()-5,points[i].y()+25,days[i].mTemHigh + "°");
    }
 
    //畫5根線
    for (int i = 0; i < 5; i++) {
        painter.drawLine(points[i],points[i+1]);
    }
}
 
void Widget::drawTempLow()
{
    QPainter painter(ui->widget_08);
    painter.setRenderHint(QPainter::Antialiasing,true);
    painter.setBrush(QBrush(QColor(53, 168, 193)));
    painter.setPen(QColor(53, 168, 193));
 
    int t_ave;
    int sum = 0;
    int offset = 0;
    int middle = ui->widget_08->height()/2;
    for (int i = 0; i < 6; i++) {
         sum += days[i].mTemLow.toUInt();
    }
    t_ave = sum / 6;
 
    //定義出6個點
    QPoint points[6];
    for (int i = 0; i < 6; i++) {
        points[i].setX(mAirqList[i]->x() + mAirqList[i]->width()/2);
        offset = (days[i].mTemLow.toInt() - t_ave)*3;
        points[i].setY(middle - offset);
        //畫點
        painter.drawEllipse(QPoint(points[i]),3,3);
        //畫實際溫度
        painter.drawText(points[i].x()-5,points[i].y()+25,days[i].mTemLow + "°");
    }
 
    //畫5根線
    for (int i = 0; i < 5; i++) {
        painter.drawLine(points[i],points[i+1]);
    }
}
 
/*
解析:/citycode.json文件的cityid與cityname,獲取不同城市的天氣
QString getCityCodeFromName(QString name)
{
    //打開文件,獲取城市的名字,id
    QFile file(":/citycode.json");
    file.open(QIODevice::ReadOnly);
    QByteArray rawData = file.readAll();
    file.close();
    //把文件QByteArray轉成QJsonDocument
    QJsonDocument jsonDoc = QJsonDocument::fromJson(rawData);
    //判斷是不是數組,QJsonDocument轉為QJsonArray
    if(jsonDoc.isArray()){
        QJsonArray citys = jsonDoc.array();
        //遍尋數組,用QJsonValue遍尋
        for(QJsonValue value:citys){
            //判斷數組是不是QJsonObject,將QJsonArray轉為QJsonObject
            if(value.isObject()){
                QJsonObject cityName = value.toObject();
                //獲取城市名字
                QString cityname = cityName["city_name"].toString();
                //判斷該城市名是否與文本一致,是返回城市id
                if(cityname == name){
                    return cityName["city_code"].toString();
                }
            }
        }
        //遍尋未找到該城市,返回空字符
        return "";
    }
}
*/
 
/* 按鍵觸發 */
void Widget::on_pushButton_clicked()
{
    //讀取文本的城市名稱
    QString cityName = ui->lineEdit_ReaserchCity->text();
    //返回的值城市id
    QString cityCode = citycodeutils.getCityCodeFromName(cityName);
    //如果有返回值,重新獲取該地區的天氣
    if(cityCode != NULL){
        strurl += "&cityid=" + cityCode;
        mannager->get(QNetworkRequest(QUrl(strurl)));
    }
    //如果返回空字符,顯示一個錯誤提示
    else{
        QMessageBox msgBox;
        msgBox.setWindowTitle("錯誤");
        msgBox.setText("請輸入正確的城市名稱");
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.exec();
    }
}
 
 
/* 回車確認按鍵 */
void Widget::on_lineEdit_ReaserchCity_returnPressed()
{
    on_pushButton_clicked();
}

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

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

相關文章

操作系統筆記(關于進程引入和狀態的切換)

1.前言 今天下午結束了英語的四六級考試&#xff0c;終于是結束了&#xff0c;最近的這個考試太密集&#xff0c;周四的專業基礎課考試&#xff0c;周五的這個線性代數的考試和這個周六的英語四六級考試&#xff0c;吧我都要烤焦了&#xff0c;最近也是疲于應對這個考試&#…

M1芯片macOS安裝Xinference部署大模型

如果你看的是官方手冊&#xff1a;安裝 — Xinference 千萬不要直接運行&#xff1a; pip install "xinference[all]" 會遇到幾個問題&#xff1a; 1&#xff09;Python版本如果太新可能安裝失敗 2&#xff09;全量安裝會失敗 3&#xff09;未科學上網可能會time…

【ONNX量化實戰】使用ONNX Runtime進行靜態量化

目錄 什么是量化量化實現的原理實戰準備數據執行量化 驗證量化結語 什么是量化 量化是一種常見的深度學習技術&#xff0c;其目的在于將原始的深度神經網絡權重從高位原始位數被動態縮放至低位目標尾數。例如從FP32&#xff08;32位浮點&#xff09;量化值INT8&#xff08;8位…

【量子計算】格羅弗算法

文章目錄 &#x1f50d; 一、算法原理與工作機制? 二、性能優勢&#xff1a;二次加速的體現&#x1f310; 三、應用場景?? 四、局限性與挑戰&#x1f52e; 五、未來展望&#x1f48e; 總結 格羅弗算法&#xff08;Grover’s algorithm&#xff09;是量子計算領域的核心算法之…

C++ 互斥量

在 C 中&#xff0c;互斥量&#xff08;std::mutex&#xff09;是一種用于多線程編程中保護共享資源的機制&#xff0c;防止多個線程同時訪問某個資源&#xff0c;從而避免數據競爭&#xff08;data race&#xff09;和不一致的問題。 &#x1f512; 一、基礎用法&#xff1a;s…

CSS Content符號編碼大全

資源寶整理分享&#xff1a;?https://www.httple.net? 前端開發中常用的特殊符號查詢工具&#xff0c;包含Unicode編碼和HTML實體編碼&#xff0c;方便開發者快速查找和使用各種符號。支持基本形狀、箭頭、數學符號、貨幣符號等多種分類。 前端最常用符號 圖標形狀十進制十…

RPC常見問題回答

項目流程和架構設計 1.服務端的功能&#xff1a; 1.提供rpc調用對應的函數 2.完成服務注冊 服務發現 上線/下線通知 3.提供主題的操作 (創建/刪除/訂閱/取消訂閱) 消息的發布 2.服務的模塊劃分 1.網絡通信模塊 net 底層套用的moude庫 2.應用層通信協議模塊 1.序列化 反序列化數…

【JavaEE】(3) 多線程2

一、常見的鎖策略 1、樂觀鎖和悲觀鎖 悲觀鎖&#xff1a;預測鎖沖突的概率較高。在鎖中加阻塞操作。樂觀鎖&#xff1a;預測鎖沖突的概率較低。使用忙等/版本號等&#xff0c;不產生阻塞。 2、輕量級鎖和重量級鎖 重量級鎖&#xff1a;加鎖的開銷較大&#xff0c;線程等待鎖…

創客匠人服務體系解析:知識 IP 變現的全鏈路賦能模型

在知識服務行業深度轉型期&#xff0c;創客匠人通過 “工具 陪跑 圈層” 的三維服務體系&#xff0c;構建了從 IP 定位到商業變現的完整賦能鏈條。這套經過 5 萬 知識博主驗證的模型&#xff0c;不僅解決了 “內容生產 - 流量獲取 - 用戶轉化” 的實操難題&#xff0c;更推動…

國產ARM/RISCV與OpenHarmony物聯網項目(六)SF1節點開發

一、終端節點功能設計 1. 功能說明 終端節點設計的是基于鴻蒙操作系統的 TCP 服務器程序&#xff0c;用于監測空氣質量并提供遠程控制功能。與之前的光照監測程序相比&#xff0c;這個程序使用 E53_SF1 模塊&#xff08;煙霧 / 氣體傳感器&#xff09;&#xff0c;主要功能包…

Plotly圖表全面使用指南 -- Displaying Figures in Python

文中內容僅限技術學習與代碼實踐參考&#xff0c;市場存在不確定性&#xff0c;技術分析需謹慎驗證&#xff0c;不構成任何投資建議。 在 Python 中顯示圖形 使用 Plotly 的 Python 圖形庫顯示圖形。 顯示圖形 Plotly的Python圖形庫plotly.py提供了多種顯示圖形的選項和方法…

getx用法詳細解析以及注意事項

源碼地址 在 Flutter 中&#xff0c;Get 是來自 get 包的一個輕量級、功能強大的狀態管理與路由框架&#xff0c;常用于&#xff1a; 狀態管理路由管理依賴注入&#xff08;DI&#xff09;Snackbar / Dialog / BottomSheet 管理本地化&#xff08;多語言&#xff09; 下面是 …

深度學習:人工神經網絡基礎概念

本文目錄&#xff1a; 一、什么是神經網絡二、如何構建神經網絡三、神經網絡內部狀態值和激活值 一、什么是神經網絡 人工神經網絡&#xff08;Artificial Neural Network&#xff0c; 簡寫為ANN&#xff09;也簡稱為神經網絡&#xff08;NN&#xff09;&#xff0c;是一種模仿…

Unity2D 街機風太空射擊游戲 學習記錄 #12環射道具的引入

概述 這是一款基于Unity引擎開發的2D街機風太空射擊游戲&#xff0c;筆者并不是游戲開發人&#xff0c;作者是siki學院的涼鞋老師。 筆者只是學習項目&#xff0c;記錄學習&#xff0c;同時也想幫助他人更好的學習這個項目 作者會記錄學習這一期用到的知識&#xff0c;和一些…

網站如何啟用HTTPS訪問?本地內網部署的https網站怎么在外網打開?

在互聯網的世界里&#xff0c;數據安全已經成為了每個網站和用戶都不得不面對的問題。近期&#xff0c;網絡信息泄露事件頻發&#xff0c;讓越來越多的網站開始重視起用戶數據的安全性&#xff0c;因此啟用HTTPS訪問成為了一個熱門話題。作為一名網絡安全專家&#xff0c;我希望…

計算機網絡-----詳解網絡原理TCP/IP(上)

文章目錄 &#x1f4d5;1. UDP協議??1.1 UDP的特點??1.2 基于UDP的應用層協議 &#x1f4d5;2. TCP協議??2.1 TCP協議段格式??2.2 TCP協議特點之確認應答??2.3 TCP協議特點之超時重傳??2.4 TCP協議特點之連接管理??2.5 TCP協議特點之滑動窗口??2.6 TCP協議特點…

Lora訓練

一種大模型高效訓練方式&#xff08;PEFT&#xff09; 目標&#xff1a; 訓練有限的ΔW&#xff08;權重更新矩陣&#xff09; ΔW為低秩矩陣→ΔWAB&#xff08;其中A的大小為dr, B的大小為rk&#xff0c;且r<<min(d,k)&#xff09;→ 原本要更新的dk參數量大幅度縮減…

藍牙 5.0 新特性全解析:傳輸距離與速度提升的底層邏輯(面試寶典版)

藍牙技術自 1994 年誕生以來,已經經歷了多次重大升級。作為當前主流的無線通信標準之一,藍牙 5.0 在 2016 年發布后,憑借其顯著的性能提升成為了物聯網(IoT)、智能家居、可穿戴設備等領域的核心技術。本文將深入解析藍牙 5.0 在傳輸距離和速度上的底層技術邏輯,并結合面試…

Minio使用https自簽證書

自簽證書參考&#xff1a;window和ubuntu自簽證書_windows 自簽證書-CSDN博客 // certFilePath: 直接放在 resources 目錄下 或者可以自定實現讀取邏輯 // 讀取的是 .crt 證書文件public static OkHttpClient createTrustingOkHttpClient(String certFilePath) throws Excep…

汽車前縱梁焊接總成與沖壓件的高效自動化三維檢測方案

汽車主體結構件上存在很多安裝位&#xff0c;為保證汽車裝配時的準確性&#xff0c;主體結構件需要進行全方位的尺寸和孔位置精度檢測&#xff0c;以確保裝配線的主體結構件質量合格。 前縱梁焊接總成是車身框架的核心承載部件&#xff0c;焊接總成由多片鈑金沖壓件焊接組成&a…