C#语言实例源码系列-实现Linq操作Xml

news2024/11/17 22:16:59
专栏分享
  • 点击跳转=>Unity3D特效百例
  • 点击跳转=>案例项目实战源码
  • 点击跳转=>游戏脚本-辅助自动化
  • 点击跳转=>Android控件全解手册

👉关于作者

众所周知,人生是一个漫长的流程,不断克服困难,不断反思前进的过程。在这个过程中会产生很多对于人生的质疑和思考,于是我决定将自己的思考,经验和故事全部分享出来,以此寻找共鸣 !!!
专注于Android/Unity和各种游戏开发技巧,以及各种资源分享(网站、工具、素材、源码、游戏等)
有什么需要欢迎私我,交流群让学习不再孤单

在这里插入图片描述

👉实践过程

😜效果

在这里插入图片描述

😜代码

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    static string strPath = "Employee.xml";
    static string strID = "";

    //窗体加载时加载XML文件
    private void Form1_Load(object sender, EventArgs e)
    {
        if (File.Exists(strPath))
        {
            groupBox1.Enabled = false;
            getXmlInfo();
        }
        else
            groupBox1.Enabled = true;
    }

    //创建XML文件
    private void button1_Click(object sender, EventArgs e)
    {
        XDocument doc = new XDocument(
            new XDeclaration("1.0", "utf-8", "yes"),
            new XElement(textBox1.Text,
                new XElement(textBox2.Text, new XAttribute(textBox3.Text, textBox10.Text),
                    new XElement(textBox4.Text, textBox5.Text),
                    new XElement(textBox6.Text, textBox7.Text),
                    new XElement(textBox8.Text, textBox9.Text))
                )
            );
        doc.Save(strPath);
        groupBox1.Enabled = false;
        getXmlInfo();
    }

    //添加XML元素
    private void button2_Click(object sender, EventArgs e)
    {
        XElement xe = XElement.Load(strPath);
        IEnumerable<XElement> elements1 = from element in xe.Elements("People")
                                          select element;
        //生成新的编号
        string str = (Convert.ToInt32(elements1.Max(element => element.Attribute("ID").Value)) + 1).ToString("000");
        XElement people = new XElement(
            "People", new XAttribute("ID", str),
            new XElement("Name", textBox11.Text),
            new XElement("Sex", comboBox1.Text),
            new XElement("Salary", textBox12.Text)
            );
        xe.Add(people);
        xe.Save(strPath);
        getXmlInfo();
    }

    //修改XML元素
    private void button3_Click(object sender, EventArgs e)
    {
        if (strID != "")
        {
            XElement xe = XElement.Load(strPath);
            IEnumerable<XElement> elements = from element in xe.Elements("People")
                                             where element.Attribute("ID").Value == strID
                                             select element;
            if (elements.Count() > 0)
            {
                XElement newXE = elements.First();
                newXE.SetAttributeValue("ID", strID);
                newXE.ReplaceNodes(
                    new XElement("Name", textBox11.Text),
                    new XElement("Sex", comboBox1.Text),
                    new XElement("Salary", textBox12.Text)
                    );
            }
            xe.Save(strPath);
        } 
        getXmlInfo();
    }

    //删除XML元素
    private void button4_Click(object sender, EventArgs e)
    {
        if (strID != "")
        {
            XElement xe = XElement.Load(strPath);
            IEnumerable<XElement> elements = from element in xe.Elements("People")
                                             where element.Attribute("ID").Value == strID
                                             select element;
            if (elements.Count() > 0)
                elements.First().Remove();
            xe.Save(strPath);
        }
        getXmlInfo();
    }

    //显示选中XML节点的详细信息
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        strID = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
        XElement xe = XElement.Load(strPath);
        IEnumerable<XElement> elements = from PInfo in xe.Elements("People")
                                         where PInfo.Attribute("ID").Value == strID
                                         select PInfo;
        foreach (XElement element in elements)
        {
            textBox11.Text = element.Element("Name").Value;
            comboBox1.SelectedItem = element.Element("Sex").Value;
            textBox12.Text = element.Element("Salary").Value;
        }
    }

    #region 将XML文件内容绑定到DataGridView控件
    /// <summary>
    /// 将XML文件内容绑定到DataGridView控件
    /// </summary>
    private void getXmlInfo()
    {
        DataSet myds = new DataSet();
        myds.ReadXml(strPath);
        dataGridView1.DataSource = myds.Tables[0];
    }
    #endregion
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.groupBox1 = new System.Windows.Forms.GroupBox();
        this.textBox10 = new System.Windows.Forms.TextBox();
        this.label10 = new System.Windows.Forms.Label();
        this.button1 = new System.Windows.Forms.Button();
        this.textBox9 = new System.Windows.Forms.TextBox();
        this.label8 = new System.Windows.Forms.Label();
        this.textBox8 = new System.Windows.Forms.TextBox();
        this.label9 = new System.Windows.Forms.Label();
        this.textBox7 = new System.Windows.Forms.TextBox();
        this.label2 = new System.Windows.Forms.Label();
        this.textBox6 = new System.Windows.Forms.TextBox();
        this.label7 = new System.Windows.Forms.Label();
        this.textBox5 = new System.Windows.Forms.TextBox();
        this.label5 = new System.Windows.Forms.Label();
        this.textBox4 = new System.Windows.Forms.TextBox();
        this.label6 = new System.Windows.Forms.Label();
        this.textBox3 = new System.Windows.Forms.TextBox();
        this.label3 = new System.Windows.Forms.Label();
        this.textBox2 = new System.Windows.Forms.TextBox();
        this.label4 = new System.Windows.Forms.Label();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.label1 = new System.Windows.Forms.Label();
        this.groupBox2 = new System.Windows.Forms.GroupBox();
        this.button4 = new System.Windows.Forms.Button();
        this.button3 = new System.Windows.Forms.Button();
        this.button2 = new System.Windows.Forms.Button();
        this.comboBox1 = new System.Windows.Forms.ComboBox();
        this.textBox12 = new System.Windows.Forms.TextBox();
        this.label12 = new System.Windows.Forms.Label();
        this.label13 = new System.Windows.Forms.Label();
        this.textBox11 = new System.Windows.Forms.TextBox();
        this.label14 = new System.Windows.Forms.Label();
        this.dataGridView1 = new System.Windows.Forms.DataGridView();
        this.groupBox1.SuspendLayout();
        this.groupBox2.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
        this.SuspendLayout();
        // 
        // groupBox1
        // 
        this.groupBox1.Controls.Add(this.textBox10);
        this.groupBox1.Controls.Add(this.label10);
        this.groupBox1.Controls.Add(this.button1);
        this.groupBox1.Controls.Add(this.textBox9);
        this.groupBox1.Controls.Add(this.label8);
        this.groupBox1.Controls.Add(this.textBox8);
        this.groupBox1.Controls.Add(this.label9);
        this.groupBox1.Controls.Add(this.textBox7);
        this.groupBox1.Controls.Add(this.label2);
        this.groupBox1.Controls.Add(this.textBox6);
        this.groupBox1.Controls.Add(this.label7);
        this.groupBox1.Controls.Add(this.textBox5);
        this.groupBox1.Controls.Add(this.label5);
        this.groupBox1.Controls.Add(this.textBox4);
        this.groupBox1.Controls.Add(this.label6);
        this.groupBox1.Controls.Add(this.textBox3);
        this.groupBox1.Controls.Add(this.label3);
        this.groupBox1.Controls.Add(this.textBox2);
        this.groupBox1.Controls.Add(this.label4);
        this.groupBox1.Controls.Add(this.textBox1);
        this.groupBox1.Controls.Add(this.label1);
        this.groupBox1.Location = new System.Drawing.Point(6, 3);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new System.Drawing.Size(451, 190);
        this.groupBox1.TabIndex = 18;
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "创建XML文件";
        // 
        // textBox10
        // 
        this.textBox10.Location = new System.Drawing.Point(319, 47);
        this.textBox10.Name = "textBox10";
        this.textBox10.ReadOnly = true;
        this.textBox10.Size = new System.Drawing.Size(119, 21);
        this.textBox10.TabIndex = 3;
        this.textBox10.Text = "001";
        // 
        // label10
        // 
        this.label10.AutoSize = true;
        this.label10.Location = new System.Drawing.Point(236, 50);
        this.label10.Name = "label10";
        this.label10.Size = new System.Drawing.Size(89, 12);
        this.label10.TabIndex = 21;
        this.label10.Text = "子节点属性值:";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(363, 158);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 10;
        this.button1.Text = "创建";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // textBox9
        // 
        this.textBox9.Location = new System.Drawing.Point(319, 131);
        this.textBox9.Name = "textBox9";
        this.textBox9.Size = new System.Drawing.Size(119, 21);
        this.textBox9.TabIndex = 9;
        // 
        // label8
        // 
        this.label8.AutoSize = true;
        this.label8.Location = new System.Drawing.Point(236, 134);
        this.label8.Name = "label8";
        this.label8.Size = new System.Drawing.Size(89, 12);
        this.label8.TabIndex = 18;
        this.label8.Text = "第三个元素值:";
        // 
        // textBox8
        // 
        this.textBox8.Location = new System.Drawing.Point(111, 131);
        this.textBox8.Name = "textBox8";
        this.textBox8.ReadOnly = true;
        this.textBox8.Size = new System.Drawing.Size(119, 21);
        this.textBox8.TabIndex = 8;
        this.textBox8.Text = "Salary";
        // 
        // label9
        // 
        this.label9.AutoSize = true;
        this.label9.Location = new System.Drawing.Point(12, 134);
        this.label9.Name = "label9";
        this.label9.Size = new System.Drawing.Size(101, 12);
        this.label9.TabIndex = 16;
        this.label9.Text = "第三个元素名称:";
        // 
        // textBox7
        // 
        this.textBox7.Location = new System.Drawing.Point(319, 103);
        this.textBox7.Name = "textBox7";
        this.textBox7.Size = new System.Drawing.Size(119, 21);
        this.textBox7.TabIndex = 7;
        // 
        // label2
        // 
        this.label2.AutoSize = true;
        this.label2.Location = new System.Drawing.Point(236, 106);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(89, 12);
        this.label2.TabIndex = 14;
        this.label2.Text = "第二个元素值:";
        // 
        // textBox6
        // 
        this.textBox6.Location = new System.Drawing.Point(111, 103);
        this.textBox6.Name = "textBox6";
        this.textBox6.ReadOnly = true;
        this.textBox6.Size = new System.Drawing.Size(119, 21);
        this.textBox6.TabIndex = 6;
        this.textBox6.Text = "Sex";
        // 
        // label7
        // 
        this.label7.AutoSize = true;
        this.label7.Location = new System.Drawing.Point(12, 106);
        this.label7.Name = "label7";
        this.label7.Size = new System.Drawing.Size(101, 12);
        this.label7.TabIndex = 12;
        this.label7.Text = "第二个元素名称:";
        // 
        // textBox5
        // 
        this.textBox5.Location = new System.Drawing.Point(319, 75);
        this.textBox5.Name = "textBox5";
        this.textBox5.Size = new System.Drawing.Size(119, 21);
        this.textBox5.TabIndex = 5;
        // 
        // label5
        // 
        this.label5.AutoSize = true;
        this.label5.Location = new System.Drawing.Point(236, 78);
        this.label5.Name = "label5";
        this.label5.Size = new System.Drawing.Size(89, 12);
        this.label5.TabIndex = 10;
        this.label5.Text = "第一个元素值:";
        // 
        // textBox4
        // 
        this.textBox4.Location = new System.Drawing.Point(111, 75);
        this.textBox4.Name = "textBox4";
        this.textBox4.ReadOnly = true;
        this.textBox4.Size = new System.Drawing.Size(119, 21);
        this.textBox4.TabIndex = 4;
        this.textBox4.Text = "Name";
        // 
        // label6
        // 
        this.label6.AutoSize = true;
        this.label6.Location = new System.Drawing.Point(12, 78);
        this.label6.Name = "label6";
        this.label6.Size = new System.Drawing.Size(101, 12);
        this.label6.TabIndex = 8;
        this.label6.Text = "第一个元素名称:";
        // 
        // textBox3
        // 
        this.textBox3.Location = new System.Drawing.Point(111, 47);
        this.textBox3.Name = "textBox3";
        this.textBox3.ReadOnly = true;
        this.textBox3.Size = new System.Drawing.Size(119, 21);
        this.textBox3.TabIndex = 2;
        this.textBox3.Text = "ID";
        // 
        // label3
        // 
        this.label3.AutoSize = true;
        this.label3.Location = new System.Drawing.Point(28, 50);
        this.label3.Name = "label3";
        this.label3.Size = new System.Drawing.Size(77, 12);
        this.label3.TabIndex = 6;
        this.label3.Text = "子节点属性:";
        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(319, 20);
        this.textBox2.Name = "textBox2";
        this.textBox2.ReadOnly = true;
        this.textBox2.Size = new System.Drawing.Size(119, 21);
        this.textBox2.TabIndex = 1;
        this.textBox2.Text = "People";
        // 
        // label4
        // 
        this.label4.AutoSize = true;
        this.label4.Location = new System.Drawing.Point(248, 23);
        this.label4.Name = "label4";
        this.label4.Size = new System.Drawing.Size(77, 12);
        this.label4.TabIndex = 4;
        this.label4.Text = "子节点名称:";
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(111, 20);
        this.textBox1.Name = "textBox1";
        this.textBox1.ReadOnly = true;
        this.textBox1.Size = new System.Drawing.Size(119, 21);
        this.textBox1.TabIndex = 0;
        this.textBox1.Text = "Peoples";
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(19, 23);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(89, 12);
        this.label1.TabIndex = 0;
        this.label1.Text = "顶级节点名称:";
        // 
        // groupBox2
        // 
        this.groupBox2.Controls.Add(this.button4);
        this.groupBox2.Controls.Add(this.button3);
        this.groupBox2.Controls.Add(this.button2);
        this.groupBox2.Controls.Add(this.comboBox1);
        this.groupBox2.Controls.Add(this.textBox12);
        this.groupBox2.Controls.Add(this.label12);
        this.groupBox2.Controls.Add(this.label13);
        this.groupBox2.Controls.Add(this.textBox11);
        this.groupBox2.Controls.Add(this.label14);
        this.groupBox2.Location = new System.Drawing.Point(6, 198);
        this.groupBox2.Name = "groupBox2";
        this.groupBox2.Size = new System.Drawing.Size(451, 80);
        this.groupBox2.TabIndex = 19;
        this.groupBox2.TabStop = false;
        this.groupBox2.Text = "操作XML文件";
        // 
        // button4
        // 
        this.button4.Location = new System.Drawing.Point(360, 47);
        this.button4.Name = "button4";
        this.button4.Size = new System.Drawing.Size(63, 23);
        this.button4.TabIndex = 16;
        this.button4.Text = "删除";
        this.button4.UseVisualStyleBackColor = true;
        this.button4.Click += new System.EventHandler(this.button4_Click);
        // 
        // button3
        // 
        this.button3.Location = new System.Drawing.Point(291, 47);
        this.button3.Name = "button3";
        this.button3.Size = new System.Drawing.Size(63, 23);
        this.button3.TabIndex = 15;
        this.button3.Text = "修改";
        this.button3.UseVisualStyleBackColor = true;
        this.button3.Click += new System.EventHandler(this.button3_Click);
        // 
        // button2
        // 
        this.button2.Location = new System.Drawing.Point(222, 47);
        this.button2.Name = "button2";
        this.button2.Size = new System.Drawing.Size(63, 23);
        this.button2.TabIndex = 14;
        this.button2.Text = "添加";
        this.button2.UseVisualStyleBackColor = true;
        this.button2.Click += new System.EventHandler(this.button2_Click);
        // 
        // comboBox1
        // 
        this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
        this.comboBox1.FormattingEnabled = true;
        this.comboBox1.Items.AddRange(new object[] {
        "男",
        "女"});
        this.comboBox1.Location = new System.Drawing.Point(286, 20);
        this.comboBox1.Name = "comboBox1";
        this.comboBox1.Size = new System.Drawing.Size(121, 20);
        this.comboBox1.TabIndex = 12;
        // 
        // textBox12
        // 
        this.textBox12.Location = new System.Drawing.Point(85, 49);
        this.textBox12.Name = "textBox12";
        this.textBox12.Size = new System.Drawing.Size(119, 21);
        this.textBox12.TabIndex = 13;
        // 
        // label12
        // 
        this.label12.AutoSize = true;
        this.label12.Location = new System.Drawing.Point(19, 52);
        this.label12.Name = "label12";
        this.label12.Size = new System.Drawing.Size(65, 12);
        this.label12.TabIndex = 27;
        this.label12.Text = "职工薪水:";
        // 
        // label13
        // 
        this.label13.AutoSize = true;
        this.label13.Location = new System.Drawing.Point(220, 23);
        this.label13.Name = "label13";
        this.label13.Size = new System.Drawing.Size(65, 12);
        this.label13.TabIndex = 25;
        this.label13.Text = "职工性别:";
        // 
        // textBox11
        // 
        this.textBox11.Location = new System.Drawing.Point(85, 20);
        this.textBox11.Name = "textBox11";
        this.textBox11.Size = new System.Drawing.Size(119, 21);
        this.textBox11.TabIndex = 11;
        // 
        // label14
        // 
        this.label14.AutoSize = true;
        this.label14.Location = new System.Drawing.Point(19, 23);
        this.label14.Name = "label14";
        this.label14.Size = new System.Drawing.Size(65, 12);
        this.label14.TabIndex = 23;
        this.label14.Text = "职工姓名:";
        // 
        // dataGridView1
        // 
        this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
        this.dataGridView1.Location = new System.Drawing.Point(6, 284);
        this.dataGridView1.Name = "dataGridView1";
        this.dataGridView1.RowTemplate.Height = 23;
        this.dataGridView1.Size = new System.Drawing.Size(451, 171);
        this.dataGridView1.TabIndex = 17;
        this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(462, 460);
        this.Controls.Add(this.dataGridView1);
        this.Controls.Add(this.groupBox2);
        this.Controls.Add(this.groupBox1);
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "使用Linq To XML操作XML文件";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.groupBox1.ResumeLayout(false);
        this.groupBox1.PerformLayout();
        this.groupBox2.ResumeLayout(false);
        this.groupBox2.PerformLayout();
        ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox textBox5;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.TextBox textBox4;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.TextBox textBox3;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.TextBox textBox7;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox textBox6;
    private System.Windows.Forms.Label label7;
    private System.Windows.Forms.TextBox textBox9;
    private System.Windows.Forms.Label label8;
    private System.Windows.Forms.TextBox textBox8;
    private System.Windows.Forms.Label label9;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.TextBox textBox10;
    private System.Windows.Forms.Label label10;
    private System.Windows.Forms.GroupBox groupBox2;
    private System.Windows.Forms.DataGridView dataGridView1;
    private System.Windows.Forms.TextBox textBox12;
    private System.Windows.Forms.Label label12;
    private System.Windows.Forms.Label label13;
    private System.Windows.Forms.TextBox textBox11;
    private System.Windows.Forms.Label label14;
    private System.Windows.Forms.ComboBox comboBox1;
    private System.Windows.Forms.Button button4;
    private System.Windows.Forms.Button button3;
    private System.Windows.Forms.Button button2;
}

需要的再直接Call我,直接发。

👉其他

📢作者:小空和小芝中的小空
📢转载说明-务必注明来源:https://zhima.blog.csdn.net/
📢这位道友请留步☁️,我观你气度不凡,谈吐间隐隐有王者霸气💚,日后定有一番大作为📝!!!旁边有点赞👍收藏🌟今日传你,点了吧,未来你成功☀️,我分文不取,若不成功⚡️,也好回来找我。

温馨提示点击下方卡片获取更多意想不到的资源。
空名先生

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

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

相关文章

Python基于PyTorch实现BP神经网络ANN回归模型项目实战

说明&#xff1a;这是一个机器学习实战项目&#xff08;附带数据代码文档视频讲解&#xff09;&#xff0c;如需数据代码文档视频讲解可以直接到文章最后获取。 1.项目背景 在人工神经网络的发展历史上&#xff0c;感知机(Multilayer Perceptron&#xff0c;MLP)网络曾对人工神…

外包三年半太差劲,才幡然醒悟要跳槽

前几天有个读者过来说&#xff0c;“程序猿&#xff0c;外包干了三年半&#xff0c;感觉和外界差距有点大&#xff0c;现在被动醒悟&#xff0c;希望你能帮我制定一下学习路线。” 如果不是女朋友和我提分手&#xff0c;我估计现在还没醒悟。大专生&#xff0c;18年通过校招进…

算法训练 —— 数组(1)

目录 一、二分查找的基本原理 二、二分查找的基本写法 三、二分查找的相关例题 1. LeetCode704.二分查找 2. LeetCode35.搜索插入位置 3. LeetCode34.在排序数组中查找的第一个和最后一个位置 4. LeetCode69.x的平方根 5. LeetCode367.有效的完全平方数 一、二分查找…

华为手表开发:WATCH 3 Pro(2)生成密钥和证书请求文件,生成签名和配置签名

华为手表开发&#xff1a;WATCH 3 Pro&#xff08;2&#xff09;生成密钥和证书请求文件&#xff0c;生成签名和配置签名初环境与设备生成密钥生成签名初 希望能写一些简单的教程和案例分享给需要的人 环境与设备 系统&#xff1a;window 设备&#xff1a;HUAWEI WATCH 3 Pr…

12.28日报

今天主要进行了资产盘点工作&#xff1b; 写了一个数据库的增删改查的接口框架&#xff1b; 遇到的问题与解决&#xff1a; Insert没使用过&#xff0c;查阅资料&#xff0c;对其初步了解 postMan使用不熟练&#xff0c;搜索配置方法&#xff0c;多练习 网关服务 基本原理…

大话设计模型 Task06:桥接、职责链、中介

目录一、桥接模式问题描述问题分析模式定义代码实现二、职责链模式问题描述问题分析模式定义代码实现三、中介模式问题描述问题分析模式定义优缺点代码实现四、命令模式&#xff08;后补&#xff09;问题描述问题分析模式定义代码实现五、享元模式&#xff08;后补&#xff09;…

面向制造业的文档管理

面向制造业的文档管理 借助DocuWare领先的文档管理和工作流程自动化解决方案&#xff0c;各行业制造商&#xff08;从金属制造和机器零件到生物技术和制药&#xff09;都可以获得具有成本效益的可持续解决方案&#xff0c;通过自动化工作流程&#xff0c;简化生产和管理流程。…

文件压缩与远程拷贝_Tar_Scp_Rsync

Tar 压缩文件类型分为&#xff1a;gzip,bzip2,xz.利用tar工具来解压&#xff0c;压缩。 tar common:#tar [option ] file_name -c 创建一个压缩包 -t 查看内容 -x 提取 -f 文件名&#xff08;必须用&#xff09; -v 详细过程 -j bzip2 -z gzip -J xz Meth: tar -czvf arch_n…

示波器应用(一)

程序同学有没有一种感觉&#xff0c;有时候看到游戏场景有一种难以言表的不舒服&#xff0c;但是又不知道画面到底为什么不舒服。美术同学看到好的作品想要”借鉴“&#xff0c;但是又无从下手。那么下面这套工具将会非常适合进行画面分析以及画面仿色。让程序看懂画面信息&…

Ansys Speos | 进行智能手机镜头杂散光分析

本例的目的是研究智能手机Camera系统的杂散光。杂散光是指光向相机传感器不需要的散光光或镜面光&#xff0c;是在光学设计中无意产生的&#xff0c;会降低相机系统的光学性能。 在本例中&#xff0c;光学透镜系统使用Ansys Zemax OpticStudio (ZOS)进行设计&#xff0c;并使用…

微信小程序会议OA-后台数据交互(首页)05

1.后台准备 1.1 pom.xml <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache…

Charles -抓不到包常见原因之证书过期失效处理方法

当出现环境配置正常但却无法抓包的时候&#xff0c;可能是因为证书失效了&#xff0c;这种情况移除旧证书&#xff0c;安装新的证书即可。 一、判断是否证书过期 iOS手机&#xff1a; 进入&#xff1a;设置 > 通用 > VPN与设备管理 > Charles Proxy CA... > 更多…

劲爆美女来袭,这不得用python高清保存防止她被封禁

前言 大家早好、午好、晚好吖 ❤ ~ 环境使用: Python 3.8 解释器 Pycharm 编辑器 模块使用: requests 数据请求 第三方模块 pip install requests <工具> re <正则表达式模块> 安装python第三方模块: win R 输入 cmd 点击确定, 输入安装命令 pip install 模块…

密码学_AES加密算法

目录 简介 AES的加密过程如下&#xff08;以128位密钥为例&#xff09;&#xff1a; 异或运算 初始变换&#xff08;initial round&#xff09; 字节代换&#xff08;SubBytes&#xff09; 行位移&#xff08;ShiftRows&#xff09; 列混合&#xff08;MixColumns&#x…

Socket套接字(网络编程万字总结-附代码)

文章目录前言一、概念二、分类&#xff08;三类&#xff09;2.1 流套接字&#xff1a;使用传输层TCP协议2.2 数据报套接字&#xff1a;使用传输层UDP协议2.3 原始套接字三、UDP数据报套接字编程3.1 Java数据报套接字通信模型3.2 DatagramSocket API3.2.1 DatagramSocket 构造方…

Shell函数

1、 函数定义 格式一&#xff1a; function name() { Command sequence; } 格式二&#xff1a; name() { Command sequence); } 1、()内是没有参数的&#xff0c;他只是函数定义的固定格式。 2、第八行fun 是函数的调用(第一种方式) 2、 函数传参 1、在Shell中&#xff0c;调用…

Jina 实例秀|基于CLIP模型的跨模态视频搜索

不同于传统的关键词搜索&#xff0c;你不需要给每个视频素材人为地打上标签。使用开源产品 CLIP-as-service&#xff0c;输入画面的描述文本&#xff0c;直接搜索到对应的视频片段。CLIP 是一个强大的模型&#xff0c;能够很好地判别文本和图片是否相关&#xff0c;但将其集成到…

【LeetCode】验证二叉搜索树 [M]

98. 验证二叉搜索树 - 力扣&#xff08;LeetCode&#xff09; 一、题目 给你一个二叉树的根节点 root &#xff0c;判断其是否是一个有效的二叉搜索树。 有效 二叉搜索树定义如下&#xff1a; 节点的左子树只包含 小于 当前节点的数。节点的右子树只包含 大于 当前节点的数。…

微信小程序框架02

目录 1.框架简介 2.视图层 View 2.2 WXML 2.3 WXSS 2.4 JS 3.事件 4.逻辑层 APP service 4.1 生命周期 4.2 页面路由 4.3模块化 1.框架简介 小程序开发框架的目标是通过尽可能简单、高效的方式让开发者可以在微信中开发具有原生 APP 体验的服务。 整个小程序框架系统分为两部…

山东大学机器学习课程资源索引

实验 完整实验代码获取 github repo 【ML实验4】多分类贝叶斯模型 【ML实验5】SVM&#xff08;手写数字识别、核方法&#xff09; 【ML实验6】K-means&#xff08;图像压缩&#xff09; 【ML实验7】人脸识别综合项目&#xff08;PCA、多分类SVM&#xff09; 一个PCA加速技巧 …