C# 学习笔记

2023-11-17

不再是学生了,成了社畜了,公司主要技术栈是C#
大一时候学C#学的很迷糊,总要重新学一下
入职已经20天了,也开始上手简单增删改查了
记录了一些C#相关的东西,只是还没有系统整理

WinForm

控件命名规范
image-20230705080620883

ADO.NET

连接数据库 Connection 对象

string constr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.20.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=abac)));User ID=abac;Password=abac";
OracleConnection con = new OracleConnection(constr);//连接到数据库
this.con.Open();

ConnectionState 枚举

image-20230705101138391

关闭连接

Dispose 和 Close

Close用于关闭一个连接,而Dispose方法不仅关闭一个连接,而且还清理连接所占用的资源。当调用Close方法关闭连接后,还可以再调用Open方法打开连接,而如果使用Dispose方法关闭连接,就不能再调用Open方法打开连接,必须重新初始化连接再打开。

执行SQL语句 Command对象

ExecuteNonQuery()方法,返回受影响的行数

OracleCommand command = new OracleCommand("insert into " +
                                          "ABXRTEST02(SYSID,STRING1,NUMBER1,DT1) values ('" +
                                          sysid_textbox.Text + "','" + string1_textbox.Text +
                                          "','" + number1_textbox.Text + "',to_date('" +
                                          dt1_date.Text + "','yyyy-mm-dd'))", this.con);
command.ExecuteNonQuery();

ExecuteReader()方法,返回一个SqlDataReader对象

ExecuteScalar()方法,返回结果集中的第一行第一列(若结果集为空返回空引用)

读取数据 DataReader对象

HasRows()方法,返回是否有一行或多行数据

Read()方法,返回是否存在多个行

数据适配器 DataAdapter对象

查询数据并填充至DataTable

string strQuery = @"select SYSID,STRING1,NUMBER1,DT1 from ABXRTEST02 where SYSID='" + SYSID +
    "' and STRING1='" + STRING1 + "' and NUMBER1='" + NUMBER1 + "'";
OracleDataAdapter adapter = new OracleDataAdapter(strQuery, this.con);
DataTable dtResult = new DataTable();
adapter.Fill(dtResult);
adapter.Dispose();

DataSet对象

相当于存放于内存的小型数据库,可以包含数据表、数据列、数据行、视图、约束关系等信息

合并DataSet内容

Merge(DataSet ds, bool Pc, MissingSchemaAction msa)方法

ds:被合并的数据和架构

pc:要保留当前DataSet中的更改则为true,否则为false

msa:MissingSchemaAction枚举值之一

image-20230706140155318

复制DataSet内容

Copy()方法,返回一个DataSet的副本

FreeSQL

数据库连接单例

using System;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Demo_7_4 {
    public class DB {
        static Lazy<IFreeSql> oracleLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
            .UseConnectionString(FreeSql.DataType.Oracle, "user id=abac;password=abac;data source=//10.168.8.1:1521/oradbsgl;Pooling=true;Max Pool Size=2")
            .UseAutoSyncStructure(true)
            .UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
            .UseNoneCommandParameter(true)
            .UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText))
            .Build());
        public static IFreeSql oracle => oracleLazy.Value;
    }
}

fsql.Insert(new ABXRTEST02 {
    STRING1 = txtString1.Text,
    NUMBER1 = int.Parse(txtNumber1.Text),
    DT1 = dtpickerDt1.Value
}).ExecuteAffrows();

fsql.Delete<ABXRTEST02>()
    .Where(b => b.SYSID == this.curIdx)
    .ExecuteAffrows();

fsql.Update<ABXRTEST02>()
    .Set(b => b.STRING1, txtString1.Text)
    .Set(b => b.NUMBER1, int.Parse(txtNumber1.Text))
    .Set(b => b.DT1, dtpickerDt1.Value)
    .Where(b => b.SYSID == this.SYSID)
    .ExecuteAffrows();

fsql.Select<ABXRTEST02>()
    .Where(a => a.SYSID == this.SYSID)
    .ToList();
fsql.Select<ABXRTEST02>().ToList();

实操

C#连接Oracle

数据表结构

首先是数据表结构如下

image-20230704163005075

WinForm界面

界面如下

image-20230704163203853

界面注意点:

DT1 对应的 DateTimePickerFormat 属性改为 Short

STRING1 的数据列为nvarchar2(20),故其对应TextBox应设置最大长度(MaxLength)为20

SYSIDNUMBER1对应的TextBox应只能输入数字,故为其KeyPress事件添加方法如下

private void number1_textbox_KeyPress(object sender, KeyPressEventArgs e) {
    if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8) { e.Handled = true; }
}

主要代码

数据库连接代码

OracleConnection con;
string constr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.168.8.109)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=abac)));User ID=abac;Password=abac";

private void Form1_Load(object sender, EventArgs e) {
    this.con = new OracleConnection(constr);//连接到数据库
    this.con.Open();
}

获取数据列表

private void getList() {
    string cmdText = @"select SYSID,STRING1,NUMBER1,DT1 from ABXRTEST02 ";
    OracleDataAdapter adapter = new OracleDataAdapter(cmdText, constr);
    DataSet dataSet = new DataSet();
    adapter.Fill(dataSet, "QueryResult");
    adapter.Dispose();
    DataTable dt = dataSet.Tables[0];
    this.dataGridView1.Columns["SYSID"].DataPropertyName = "SYSID";
    this.dataGridView1.Columns["STRING1"].DataPropertyName = "STRING1";
    this.dataGridView1.Columns["NUMBER1"].DataPropertyName = "NUMBER1";
    this.dataGridView1.Columns["DT1"].DataPropertyName = "DT1";
    this.dataGridView1.DataSource = dt;
}

添加数据时要注意,SYSID不能重复

try {
    OracleCommand command = new OracleCommand("insert into " +
                                              "ABXRTEST02(SYSID,STRING1,NUMBER1,DT1) values ('" +
                                              sysid_textbox.Text + "','" + string1_textbox.Text +
                                              "','" + number1_textbox.Text + "',to_date('" +
                                              dt1_date.Text + "','yyyy-mm-dd'))", this.con);
    command.ExecuteNonQuery();
    command.Dispose();
    MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
    MessageBox.Show("添加失败,SYSID重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    return;
}

全部代码

Form1.cs

using System.Data;
using System.Drawing;
using Oracle.ManagedDataAccess.Client;//oracle数据提供程序

namespace Demo_7_4 {
    public partial class Form1 : Form {
        OracleConnection con;
        string constr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.168.6.29)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=abac)));User ID=abac;Password=abac";
        string flag = "";
        public Form1() {
            InitializeComponent();
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e) {
            this.sysid_textbox.Text = "";
            this.string1_textbox.Text = "";
            this.number1_textbox.Text = "";
            this.dt1_date.Text = "";
            this.sysid_textbox.Enabled = true;
            this.string1_textbox.Enabled = true;
            this.number1_textbox.Enabled = true;
            this.dt1_date.Enabled = true;
            this.button3.Enabled = false;
            this.button2.Enabled = false;
            this.add_button.Enabled = false;
            this.button1.Enabled = true;
            this.flag = "add";
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e) {
            this.sysid_textbox.Enabled = false;
            this.string1_textbox.Enabled = true;
            this.number1_textbox.Enabled = true;
            this.dt1_date.Enabled = true;
            this.button1.Enabled = true;
            this.button3.Enabled = false;
            this.button2.Enabled = false;
            this.add_button.Enabled = true;
            this.flag = "edit";
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e) {
            if ((MessageBox.Show("是否真的要删除用户" + this.sysid_textbox.Text + "吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)).Equals(DialogResult.Yes)) {
                String strQuery = "delete from ABXRTEST02 where SYSID='" + sysid_textbox.Text + "'";
                OracleCommand command = new OracleCommand(strQuery, this.con);
                int num = command.ExecuteNonQuery();
                command.Dispose();
                MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                getList();
                this.sysid_textbox.Text = "";
                this.string1_textbox.Text = "";
                this.number1_textbox.Text = "";
                this.dt1_date.Text = "";
                this.sysid_textbox.Enabled = false;
                this.string1_textbox.Enabled = false;
                this.number1_textbox.Enabled = false;
                this.button3.Enabled = false;
                this.button2.Enabled = false;
                this.button1.Enabled = false;
                this.dt1_date.Enabled = false;
            }
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) {
            DataTable dt = (DataTable)this.dataGridView1.DataSource;
            if (e.RowIndex > -1) {
                string SYSID = dt.Rows[e.RowIndex]["SYSID"].ToString();
                string STRING1 = dt.Rows[e.RowIndex]["STRING1"].ToString();
                string NUMBER1 = dt.Rows[e.RowIndex]["NUMBER1"].ToString();
                string DT1 = dt.Rows[e.RowIndex]["DT1"].ToString();
                string strQuery = @"select SYSID,STRING1,NUMBER1,DT1 from ABXRTEST02
where SYSID='" + SYSID + "' and STRING1='" + STRING1 + "' and NUMBER1='" + NUMBER1 +
"'";
                OracleDataAdapter adapter = new OracleDataAdapter(strQuery, this.constr);
                DataSet dataSet = new DataSet();
                adapter.Fill(dataSet, "QueryResult");
                adapter.Dispose();
                DataTable dtResult = dataSet.Tables[0];
                this.sysid_textbox.Text = dtResult.Rows[0]["SYSID"].ToString();
                this.string1_textbox.Text = dtResult.Rows[0]["STRING1"].ToString();
                this.number1_textbox.Text = dtResult.Rows[0]["NUMBER1"].ToString();
                this.dt1_date.Text = dtResult.Rows[0]["DT1"].ToString();
                this.button2.Enabled = true;
                this.button1.Enabled = false;
                this.add_button.Enabled = true;
                this.button3.Enabled = true;
            }
        }

        private void Form1_Load(object sender, EventArgs e) {
            this.sysid_textbox.Enabled = false;
            this.string1_textbox.Enabled = false;
            this.number1_textbox.Enabled = false;
            this.button3.Enabled = false;
            this.button2.Enabled = false;
            this.button1.Enabled = false;
            this.dt1_date.Enabled = false;
            this.con = new OracleConnection(constr);//连接到数据库
            this.con.Open();
            getList();
        }
        private void getList() {
            string cmdText = @"select SYSID,STRING1,NUMBER1,DT1 from ABXRTEST02 ";
            OracleDataAdapter adapter = new OracleDataAdapter(cmdText, constr);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "QueryResult");
            adapter.Dispose();
            DataTable dt = dataSet.Tables[0];
            this.dataGridView1.Columns["SYSID"].DataPropertyName = "SYSID";
            this.dataGridView1.Columns["STRING1"].DataPropertyName = "STRING1";
            this.dataGridView1.Columns["NUMBER1"].DataPropertyName = "NUMBER1";
            this.dataGridView1.Columns["DT1"].DataPropertyName = "DT1";
            this.dataGridView1.DataSource = dt;
        }
        private void button1_Click_1(object sender, EventArgs e) {
            if (this.string1_textbox.Text == "") {
                MessageBox.Show("STRING1不允许为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.string1_textbox.Focus();
                return;
            } else if (this.number1_textbox.Text == "") {
                MessageBox.Show("NUMBER1不允许为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.number1_textbox.Focus();
                return;
            } else if (this.dt1_date.Text == "") {
                MessageBox.Show("DT1不允许为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.dt1_date.Focus();
                return;
            }
            if (this.flag == "add") {
                try {
                    OracleCommand command = new OracleCommand("insert into " +
                    "ABXRTEST02(SYSID,STRING1,NUMBER1,DT1) values ('" + sysid_textbox.Text +
                    "','" + string1_textbox.Text + "','"
                    + number1_textbox.Text + "',to_date('"
                    + dt1_date.Text + "','yyyy-mm-dd'))", this.con);
                    command.ExecuteNonQuery();
                    command.Dispose();
                    MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                } catch (Exception ex) {
                    MessageBox.Show("添加失败,SYSID重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            } else if (this.flag == "edit") {
                OracleCommand command = new OracleCommand("update ABXRTEST02 set " +
                "STRING1='" + string1_textbox.Text + "', " +
                "NUMBER1='" + number1_textbox.Text + "', " +
                "DT1=to_date('" + dt1_date.Text + "','yyyy-mm-dd') where SYSID='" + sysid_textbox.Text + "'", this.con);
                command.ExecuteNonQuery();
                command.Dispose();
                MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            getList();
            this.button1.Enabled = false;
            this.add_button.Enabled = true;

            this.sysid_textbox.Enabled = false;
            this.string1_textbox.Enabled = false;
            this.number1_textbox.Enabled = false;
            this.dt1_date.Enabled = false;

            this.sysid_textbox.Text = "";
            this.string1_textbox.Text = "";
            this.number1_textbox.Text = "";
            this.dt1_date.Text = "";
        }

        private void number1_textbox_KeyPress(object sender, KeyPressEventArgs e) {
            if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8) { e.Handled = true; }
        }

        ~Form1() {
            this.con.Close();
        }
    }
}

Form1.Designer.cs

namespace Demo_7_4 {
    partial class Form1 {
        /// <summary>
        ///  Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        ///  Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing) {
            if (disposing && (components != null)) {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        ///  Required method for Designer support - do not modify
        ///  the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent() {
            components = new System.ComponentModel.Container();
            bindingSource1 = new BindingSource(components);
            label1 = new Label();
            label2 = new Label();
            label3 = new Label();
            label4 = new Label();
            dataGridView1 = new DataGridView();
            SYSID = new DataGridViewTextBoxColumn();
            STRING1 = new DataGridViewTextBoxColumn();
            NUMBER1 = new DataGridViewTextBoxColumn();
            DT1 = new DataGridViewTextBoxColumn();
            add_button = new Button();
            button2 = new Button();
            sysid_textbox = new TextBox();
            string1_textbox = new TextBox();
            number1_textbox = new TextBox();
            dt1_date = new DateTimePicker();
            button3 = new Button();
            button1 = new Button();
            ((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
            ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
            SuspendLayout();
            // 
            // label1
            // 
            label1.AutoSize = true;
            label1.Location = new Point(25, 42);
            label1.Name = "label1";
            label1.Size = new Size(51, 20);
            label1.TabIndex = 0;
            label1.Text = "SYSID";
            // 
            // label2
            // 
            label2.AutoSize = true;
            label2.Location = new Point(698, 42);
            label2.Name = "label2";
            label2.Size = new Size(38, 20);
            label2.TabIndex = 1;
            label2.Text = "DT1";
            // 
            // label3
            // 
            label3.AutoSize = true;
            label3.Location = new Point(465, 42);
            label3.Name = "label3";
            label3.Size = new Size(83, 20);
            label3.TabIndex = 2;
            label3.Text = "NUMBER1";
            // 
            // label4
            // 
            label4.AutoSize = true;
            label4.Location = new Point(230, 42);
            label4.Name = "label4";
            label4.Size = new Size(73, 20);
            label4.TabIndex = 3;
            label4.Text = "STRING1";
            // 
            // dataGridView1
            // 
            dataGridView1.AccessibleRole = AccessibleRole.MenuPopup;
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dataGridView1.Columns.AddRange(new DataGridViewColumn[] { SYSID, STRING1, NUMBER1, DT1 });
            dataGridView1.Location = new Point(25, 215);
            dataGridView1.Name = "dataGridView1";
            dataGridView1.ReadOnly = true;
            dataGridView1.RowHeadersWidth = 51;
            dataGridView1.RowTemplate.Height = 29;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.Size = new Size(910, 342);
            dataGridView1.TabIndex = 4;
            dataGridView1.CellContentClick += dataGridView1_CellContentClick;
            // 
            // SYSID
            // 
            SYSID.HeaderText = "SYSID";
            SYSID.MinimumWidth = 6;
            SYSID.Name = "SYSID";
            SYSID.ReadOnly = true;
            SYSID.Width = 125;
            // 
            // STRING1
            // 
            STRING1.HeaderText = "STRING1";
            STRING1.MinimumWidth = 6;
            STRING1.Name = "STRING1";
            STRING1.ReadOnly = true;
            STRING1.Width = 125;
            // 
            // NUMBER1
            // 
            NUMBER1.HeaderText = "NUMBER1";
            NUMBER1.MinimumWidth = 6;
            NUMBER1.Name = "NUMBER1";
            NUMBER1.ReadOnly = true;
            NUMBER1.Width = 125;
            // 
            // DT1
            // 
            DT1.HeaderText = "DT1";
            DT1.MinimumWidth = 6;
            DT1.Name = "DT1";
            DT1.ReadOnly = true;
            DT1.Width = 200;
            // 
            // add_button
            // 
            add_button.Location = new Point(178, 134);
            add_button.Name = "add_button";
            add_button.Size = new Size(125, 49);
            add_button.TabIndex = 5;
            add_button.Text = "添加";
            add_button.UseVisualStyleBackColor = true;
            add_button.Click += button1_Click;
            // 
            // button2
            // 
            button2.Location = new Point(369, 134);
            button2.Name = "button2";
            button2.Size = new Size(135, 49);
            button2.TabIndex = 6;
            button2.Text = "修改";
            button2.UseVisualStyleBackColor = true;
            button2.Click += button2_Click;
            // 
            // sysid_textbox
            // 
            sysid_textbox.Location = new Point(99, 39);
            sysid_textbox.Name = "sysid_textbox";
            sysid_textbox.Size = new Size(125, 27);
            sysid_textbox.TabIndex = 7;
            sysid_textbox.KeyPress += number1_textbox_KeyPress;
            // 
            // string1_textbox
            // 
            string1_textbox.Location = new Point(309, 39);
            string1_textbox.MaxLength = 20;
            string1_textbox.Name = "string1_textbox";
            string1_textbox.Size = new Size(125, 27);
            string1_textbox.TabIndex = 8;
            // 
            // number1_textbox
            // 
            number1_textbox.Location = new Point(554, 39);
            number1_textbox.Name = "number1_textbox";
            number1_textbox.Size = new Size(125, 27);
            number1_textbox.TabIndex = 9;
            number1_textbox.KeyPress += number1_textbox_KeyPress;
            // 
            // dt1_date
            // 
            dt1_date.Format = DateTimePickerFormat.Short;
            dt1_date.Location = new Point(763, 37);
            dt1_date.Name = "dt1_date";
            dt1_date.Size = new Size(172, 27);
            dt1_date.TabIndex = 11;
            // 
            // button3
            // 
            button3.Location = new Point(568, 134);
            button3.Name = "button3";
            button3.Size = new Size(135, 49);
            button3.TabIndex = 12;
            button3.Text = "删除";
            button3.UseVisualStyleBackColor = true;
            button3.Click += button3_Click;
            // 
            // button1
            // 
            button1.Location = new Point(763, 134);
            button1.Name = "button1";
            button1.Size = new Size(135, 49);
            button1.TabIndex = 13;
            button1.Text = "确定";
            button1.UseVisualStyleBackColor = true;
            button1.Click += button1_Click_1;
            // 
            // Form1
            // 
            AutoScaleDimensions = new SizeF(9F, 20F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(965, 569);
            Controls.Add(button1);
            Controls.Add(button3);
            Controls.Add(dt1_date);
            Controls.Add(number1_textbox);
            Controls.Add(string1_textbox);
            Controls.Add(sysid_textbox);
            Controls.Add(button2);
            Controls.Add(add_button);
            Controls.Add(dataGridView1);
            Controls.Add(label4);
            Controls.Add(label3);
            Controls.Add(label2);
            Controls.Add(label1);
            Name = "Form1";
            Text = "Form1";
            Load += Form1_Load;
            ((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit();
            ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
            ResumeLayout(false);
            PerformLayout();
        }

        #endregion

        private BindingSource bindingSource1;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private DataGridView dataGridView1;
        private Button add_button;
        private Button button2;
        private TextBox sysid_textbox;
        private TextBox string1_textbox;
        private TextBox number1_textbox;
        private DateTimePicker dt1_date;
        private Button button3;
        private DataGridViewTextBoxColumn SYSID;
        private DataGridViewTextBoxColumn STRING1;
        private DataGridViewTextBoxColumn NUMBER1;
        private DataGridViewTextBoxColumn DT1;
        private Button button1;
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

C# 学习笔记 的相关文章

随机推荐

  • YOLOv1,v2,v3学习笔记

    YOLO学习笔记 首先我们这篇文章只写yolov1 v2 v3 至于v4我会另起一篇博文的 因为v4中用到了很多的trick和介绍了很多trick 所以我想详细介绍一下 照例 先放大佬的链接 https zhuanlan zhihu com
  • 【数字电路基础】三态门

    目录 前言 三态门 经典问题 前言 文主要讲解三态门 三态门 其模型为 其实际电路为 其真值表为 B A C 0 0 Z 0 1 Z 1 0 0 1 1 1 注意 Z是高阻 不代表没有电压 而是电压不确定 受自身 旁边cell的影响 经典问
  • multi-head attention理解加代码

    multi head attention 用于CNN相关理解 饭前小菜 在早期的Machine Translation 机器翻译 中 Attention机制与RNN的结合 机器翻译解决的是输入是一串在某种语言中的一句话 输出是目标语言相对应
  • python通过多进程加快预处理数据集的速度

    问题背景 imageNet数据集有1000个文件夹 每个文件夹是同一类的图片 大概一两千张 需要对每张图片进行预处理 把图片变成224 224像素的 这样可以加速后续程序的IO速度 同时也方便了数据集的移动 因为更小了 但是图片数量很大 全
  • 工具功能加强-对ARL的改造

    这一阵挖了不少的洞 学习到了很多的姿势 对ARL 玩的也明白了些 下面给大家介绍下如何加强你的ARL 首先不熟悉ARL的可以访问ARL的地址 GitHub TophantTechnology ARL ARL Asset Reconnaiss
  • 嘉兴职业技术学校2019分数线计算机,嘉兴职业技术学院

    序号 入围专业 分数线 1 园艺技术 131 43 2 应用电子技术 航空电子方向 130 00 3 无人机应用技术 125 14 4 物流管理 航空物流方向 133 14 5 旅游管理 文化创意与策划方向 129 14 6 酒店管理 休闲
  • Ubuntu apt update 报错APT::Update::

    E Problem executing scripts APT Update Post Invoke Success if usr bin test w var cache app info a e usr bin appstreamcli
  • 2021年开始,Adobe Flash Player 不能用了?

    WeChat 网管小贾 www sysadm cc 我们都知道 Adobe Flash Player 以下简称 Flash 是比较古老的程序了 在80 90后一代的记忆中 Flash 曾经可是火得一塌糊涂 而炙手可热的 Flash 很多人都
  • jmp address windows hook

    以下代码是sysnap早期发表的inlinehook ObReferenceObjectByHandle 的代码 大部分看懂了 但是有些看不懂 google也查了 qq群也问了 哪位高手有时间给科普下哈 可怜下偶们菜鸟吧 declspec
  • 【Spring IoC容器的加载过程】

    加载配置文件 Spring IoC容器的配置通常以XML形式存储 并通过ResourceLoader和XmlBeanDefinitionReader类来加载 ResourceLoader主要负责加载Bean配置文件 而XmlBeanDefi
  • Java字符串分析器

    package StruingTokenizer import java util StringTokenizer public class StringTokenizer public static void main String ar
  • Docker-数据卷(Data Volumes)&dockerfile

    目录 一 宿主机与容器之间的文件拷贝 1 1 容器中怎么上传项目 文件 1 2 从宿主机拷贝文件到容器 1 3 从容器中拷贝文件到宿主机 二 数据卷 三 数据卷容器 四 Dockerfile Dockerfile制作增强版 自定义cento
  • 电商前台项目——完成注册登录功能、路由守卫

    电商前台项目 完成注册登录功能 路由守卫 文章目录 电商前台项目 完成注册登录功能 路由守卫 一 完成注册部分 1 获取验证码 2 完成用户注册 二 登录 1 点击登录发送请求校验 2 保存下发的token 3 拿着token请求用户数据并
  • 音频处理工具SOX详解

    这里写自定义目录标题 前言 一 简介 二 基本使用 三 音频效果 前言 SoX 即 Sound eXchange 是一个跨平台 Windows Linux MacOS 等 的命令行实用程序 可以将各种格式的音频文件转换为需要的其他格式 So
  • 分布式事务的 N 种实现

    需求缘起 在微服务架构中 随着服务的逐步拆分 数据库私有已经成为共识 这也导致所面临的分布式事务问题成为微服务落地过程中一个非常难以逾越的障碍 但是目前尚没有一个完整通用的解决方案 其实不仅仅是在微服务架构中 随着用户访问量的逐渐上涨 数据
  • Spring Cloud (各厂)

    参考 https zhuanlan zhihu com p 98874444 Spring Cloud Netflix Spring Cloud 官方 Spring Cloud Zookeeper Spring Cloud Consul K
  • 【数据结构与算法】不就是数据结构

    前言 嗨喽小伙伴们你们好呀 好久不见了 我已经好久没更新博文了 之前因为实习没有时间去写博文 现在已经回归校园了 我看了本学期的课程中有数据结构这门课程 这么课程特别重要 因为之前学过一点 所以就想着深入学习一下子 毕竟这门课程对于考研和就
  • 基于卷积神经网络进行股价预测(Matlab代码实现)

    目录 1 概述 2 运行结果 3 参考文献 4 Matlab代码 1 概述 CNN是一种人工神经网络 CNN的结构可以分为3层 卷积层 Convolutional Layer 主要作用是提取特征 池化层 Max Pooling Layer
  • C/C++中for循环详解,以及括号中三部分内容的含义和C++11标准for方法

    for循环语句 作用 满足循环条件 执行循环语句 语法 for 起始表达式 条件表达式 末尾循环体 循环语句 格式 for init statement condition expression statement 解析 init stat
  • C# 学习笔记

    不再是学生了 成了社畜了 公司主要技术栈是C 大一时候学C 学的很迷糊 总要重新学一下 入职已经20天了 也开始上手简单增删改查了 记录了一些C 相关的东西 只是还没有系统整理 WinForm 控件命名规范 ADO NET 连接数据库 Co