Delphi11的多线程ⓞ,附送图片处理代码

news2024/11/29 2:39:15

Delphi11的多线程ⓞ

OLD Coder , 习惯使用Pascal 接下来准备启用多线程,毕竟硬件多核,Timer不太爽了(曾经的桌面,都是Timer——理解为“片”)

突然想写写,不知道还有多少D兄弟们在。

从源码开始

用D11之前用D7,为了兼容现在的“大WEB”(utf8Code,你猜用来写的什么?)只能升级到高版本——的确提供了很多的系功能,比如Mysql、SQLITE等。
用Delphi一切必须从源码开始——不要问为什么!

在D7这里插入图片描述

D7中的 TThread

~ 依然没有Pascal代码块~

  TThread = class
  private
{$IFDEF MSWINDOWS}
    FHandle: THandle;
    FThreadID: THandle;
{$ENDIF}
{$IFDEF LINUX}
    // ** FThreadID is not THandle in Linux **
    FThreadID: Cardinal;
    FCreateSuspendedSem: TSemaphore;
    FInitialSuspendDone: Boolean;
{$ENDIF}
    FCreateSuspended: Boolean;
    FTerminated: Boolean;
    FSuspended: Boolean;
    FFreeOnTerminate: Boolean;
    FFinished: Boolean;
    FReturnValue: Integer;
    FOnTerminate: TNotifyEvent;
    FSynchronize: TSynchronizeRecord;
    FFatalException: TObject;
    procedure CallOnTerminate;
    class procedure Synchronize(ASyncRec: PSynchronizeRecord); overload;
{$IFDEF MSWINDOWS}
    function GetPriority: TThreadPriority;
    procedure SetPriority(Value: TThreadPriority);
{$ENDIF}
{$IFDEF LINUX}
    // ** Priority is an Integer value in Linux
    function GetPriority: Integer;
    procedure SetPriority(Value: Integer);
    function GetPolicy: Integer;
    procedure SetPolicy(Value: Integer);
{$ENDIF}
    procedure SetSuspended(Value: Boolean);
  protected
    procedure CheckThreadError(ErrCode: Integer); overload;
    procedure CheckThreadError(Success: Boolean); overload;
    procedure DoTerminate; virtual;
    procedure Execute; virtual; abstract;
    procedure Synchronize(Method: TThreadMethod); overload;
    property ReturnValue: Integer read FReturnValue write FReturnValue;
    property Terminated: Boolean read FTerminated;
  public
    constructor Create(CreateSuspended: Boolean);
    destructor Destroy; override;
    procedure AfterConstruction; override;
    procedure Resume;
    procedure Suspend;
    procedure Terminate;
    function WaitFor: LongWord;
    class procedure Synchronize(AThread: TThread; AMethod: TThreadMethod); overload;
    class procedure StaticSynchronize(AThread: TThread; AMethod: TThreadMethod);
    property FatalException: TObject read FFatalException;
    property FreeOnTerminate: Boolean read FFreeOnTerminate write FFreeOnTerminate;
{$IFDEF MSWINDOWS}
    property Handle: THandle read FHandle;
    property Priority: TThreadPriority read GetPriority write SetPriority;
{$ENDIF}
{$IFDEF LINUX}
    // ** Priority is an Integer **
    property Priority: Integer read GetPriority write SetPriority;
    property Policy: Integer read GetPolicy write SetPolicy;
{$ENDIF}
    property Suspended: Boolean read FSuspended write SetSuspended;
{$IFDEF MSWINDOWS}
    property ThreadID: THandle read FThreadID;
{$ENDIF}
{$IFDEF LINUX}
    // ** ThreadId is Cardinal **
    property ThreadID: Cardinal read FThreadID;
{$ENDIF}
    property OnTerminate: TNotifyEvent read FOnTerminate write FOnTerminate;
  end;

在这里插入图片描述

D11中的TThread

  TThread = class
  private type
    PSynchronizeRecord = ^TSynchronizeRecord;
    TSynchronizeRecord = record
      FThread: TObject;
      FMethod: TThreadMethod;
      FProcedure: TThreadProcedure;
      FSynchronizeException: TObject;
      FExecuteAfterTimestamp: Int64;
      procedure Init(AThread: TObject; const AMethod: TThreadMethod); overload;
      procedure Init(AThread: TObject; const AProcedure: TThreadProcedure); overload;
    end;
    TOnSynchronizeProc = reference to procedure (AThreadID: TThreadID; var AQueueEvent: Boolean;
      var AForceQueue: Boolean; var AMethod: TThreadMethod; var AProcedure: TThreadProcedure);
  private class var
    FProcessorCount: Integer;
    FOnSynchronize: TOnSynchronizeProc;
  private
    FThreadID: TThreadID;
{$IF Defined(MSWINDOWS)}
    FHandle: THandle platform;
{$ELSEIF Defined(POSIX)}
    FCreateSuspendedMutex: pthread_mutex_t;
    FInitialSuspendDone: Boolean;
    FResumeEvent: sem_t;
{$ENDIF POSIX}
    FStarted: Boolean;
    FCreateSuspended: Boolean;
    [HPPGEN('volatile bool FTerminated')]
    FTerminated: Boolean;
    FSuspended: Boolean;
    FFreeOnTerminate: Boolean;
    [HPPGEN('volatile bool FFinished')]
    FFinished: Boolean;
    FReturnValue: Integer;
    FOnTerminate: TNotifyEvent;
    FFatalException: TObject;
    FExternalThread: Boolean;
    FShutdown: Boolean;
    class constructor Create;
    class destructor Destroy;
    procedure CallOnTerminate;
    class procedure Synchronize(ASyncRec: PSynchronizeRecord; QueueEvent: Boolean = False;
      ForceQueue: Boolean = False); overload;
    class function GetCurrentThread: TThread; static;
    class function GetIsSingleProcessor: Boolean; static; inline;
    procedure InternalStart(Force: Boolean);
{$IF Defined(MSWINDOWS)}
    function GetPriority: TThreadPriority; platform;
    procedure SetPriority(Value: TThreadPriority); platform;
{$ELSEIF Defined(POSIX)}
    function GetPriority: Integer; platform;
    procedure SetPriority(Value: Integer); platform;
    function GetPolicy: Integer; platform;
    procedure SetPolicy(Value: Integer); platform;
{$ENDIF POSIX}
    procedure SetSuspended(Value: Boolean);
  private class threadvar
    [Unsafe] FCurrentThread: TThread;
  protected
    procedure CheckThreadError(ErrCode: Integer); overload;
    procedure CheckThreadError(Success: Boolean); overload;
    procedure DoTerminate; virtual;
    procedure TerminatedSet; virtual;
    procedure Execute; virtual; abstract;
    procedure Queue(AMethod: TThreadMethod); overload; inline;
    procedure Synchronize(AMethod: TThreadMethod); overload; inline;
    procedure Queue(AThreadProc: TThreadProcedure); overload; inline;
    procedure Synchronize(AThreadProc: TThreadProcedure); overload; inline;
    procedure SetFreeOnTerminate(Value: Boolean);
    procedure ShutdownThread; virtual;
    class procedure InitializeExternalThreadsList;
    property ReturnValue: Integer read FReturnValue write FReturnValue;
    property Terminated: Boolean read FTerminated;
  public type
    TSystemTimes = record
      IdleTime, UserTime, KernelTime, NiceTime: UInt64;
    end;
  public
    constructor Create; overload;
    constructor Create(CreateSuspended: Boolean); overload;
{$IF Defined(MSWINDOWS)}
    constructor Create(CreateSuspended: Boolean; ReservedStackSize: NativeUInt); overload;
{$ENDIF MSWINDOWS}
    destructor Destroy; override;
    // CreateAnonymousThread will create an instance of an internally derived TThread that simply will call the
    // anonymous method of type TProc. This thread is created as suspended, so you should call the Start method
    // to make the thread run. The thread is also marked as FreeOnTerminate, so you should not touch the returned
    // instance after calling Start as it could have run and is then freed before another external calls or
    // operations on the instance are attempted.
    class function CreateAnonymousThread(const ThreadProc: TProc): TThread; static;
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;
    // This function is not intended to be used for thread synchronization.
    procedure Resume; deprecated;
    // Use Start after creating a suspended thread.
    procedure Start;
    // This function is not intended to be used for thread synchronization.
    procedure Suspend; deprecated;
    procedure Terminate;
    function WaitFor: LongWord;
{$IF Defined(POSIX)}
    // Use Schedule on Posix platform to set both policy and priority. This is useful
    // when you need to set policy to SCHED_RR or SCHED_FIFO, and priority > 0. They
    // cannot be set sequentionally using Policy and Priority properties. Setting
    // policy to SCHED_RR or SCHED_FIFO requires root privileges.
    procedure Schedule(APolicy, APriority: Integer);
{$ENDIF POSIX}
    // NOTE: You can only call CheckTerminated and SetReturnValue on an internally created thread.
    // Calling this from an externally created thread will raise an exception
    // Use TThread.CheckTerminated to check if the Terminated flag has been set on the current thread
    class function CheckTerminated: Boolean; static;
    // Use TThread.SetReturnValue to set the current thread's return value from code that doesn't have
    // direct access to the current thread
    class procedure SetReturnValue(Value: Integer); static;
    class procedure Queue(const AThread: TThread; AMethod: TThreadMethod); overload; static;
    class procedure Queue(const AThread: TThread; AThreadProc: TThreadProcedure); overload; static;
    class procedure RemoveQueuedEvents(const AThread: TThread; AMethod: TThreadMethod); overload; static;
    class procedure StaticQueue(const AThread: TThread; AMethod: TThreadMethod); static; deprecated 'From C++ just use Queue now that it is just a static method';
    class procedure Synchronize(const AThread: TThread; AMethod: TThreadMethod); overload; static;
    class procedure Synchronize(const AThread: TThread; AThreadProc: TThreadProcedure); overload; static;
    class procedure StaticSynchronize(const AThread: TThread; AMethod: TThreadMethod); static; deprecated 'From C++ just use Synchronize now that it is just a static method';
    /// <summary>
    ///    Queue the method to delay its  synchronous execution. Unlike the Queue method, this will queue it even
    ///    if the caller is in the main thread.
    /// </summary>
    class procedure ForceQueue(const AThread: TThread; const AMethod: TThreadMethod; ADelay: Integer = 0); overload; static;
    /// <summary>
    ///    Queue the procedure to delay its synchronous execution. Unlike the Queue method, this will queue it even
    ///    if the caller is in the main thread.
    /// </summary>
    class procedure ForceQueue(const AThread: TThread; const AThreadProc: TThreadProcedure; ADelay: Integer = 0); overload; static;
    class procedure RemoveQueuedEvents(const AThread: TThread); overload; static;
    class procedure RemoveQueuedEvents(AMethod: TThreadMethod); overload; static; inline;
{$IFNDEF NEXTGEN}
    class procedure NameThreadForDebugging(AThreadName: AnsiString; AThreadID: TThreadID = TThreadID(-1)); overload; static; //deprecated 'Use without AnsiString cast';
{$ENDIF !NEXTGEN}
    class procedure NameThreadForDebugging(AThreadName: string; AThreadID: TThreadID = TThreadID(-1)); overload; static;
    class procedure SpinWait(Iterations: Integer); static;
    class procedure Sleep(Timeout: Integer); static;
    class procedure Yield; static;
    // Call GetSystemTimes to get the current CPU ticks representing the amount of time the system has
    // spent Idle, in User's code, in Kernel or System code and Nice. For many systems, such as Windows,
    // the NiceTime is 0. NOTE: The KernelTime field also include the amount of time the system has been Idle.
    class function GetSystemTimes(out SystemTimes: TSystemTimes): Boolean; static;
    // Using the previously acquired SystemTimes structure, calculate the average time that the CPU has been
    // executing user and kernel code. This is the current CPU load the system is experiencing. The return value
    // is expressed as a percentage ranging from 0 to 100. NOTE: The passed in PrevSystemTimes record is updated
    // with the current system time values.
    class function GetCPUUsage(var PrevSystemTimes: TSystemTimes): Integer; static;
    // Returns current value in milliseconds of an internal system counter
    class function GetTickCount: Cardinal; static;
    // Returns current value in milliseconds of an internal system counter with 64bits
    class function GetTickCount64: UInt64; static;
    /// <summary>
    ///    Returns True if after AStartTime the specified ATimeout is passed.
    ///    When ATimeout <= 0, then timeout is inifinite and function always returns False.
    /// </summary>
    class function IsTimeout(AStartTime: Cardinal; ATimeout: Integer): Boolean; static;
    property ExternalThread: Boolean read FExternalThread;
    property FatalException: TObject read FFatalException;
    property FreeOnTerminate: Boolean read FFreeOnTerminate write SetFreeOnTerminate;
    property Finished: Boolean read FFinished;
{$IF Defined(MSWINDOWS)}
    property Handle: THandle read FHandle;
    property Priority: TThreadPriority read GetPriority write SetPriority;
{$ELSEIF Defined(POSIX)}
    // ** Priority is an Integer **
    property Priority: Integer read GetPriority write SetPriority;
    property Policy: Integer read GetPolicy write SetPolicy;
{$ENDIF POSIX}
    // Started is set to true once the thread has actually started running after the initial suspend.
    property Started: Boolean read FStarted;
    property Suspended: Boolean read FSuspended write SetSuspended;
    property ThreadID: TThreadID read FThreadID;
    property OnTerminate: TNotifyEvent read FOnTerminate write FOnTerminate;
    /// <summary>
    ///    The currently executing thread. This is the same as TThread.CurrentThread.
    /// </summary>
    class property Current: TThread read GetCurrentThread;
    /// <summary>
    ///    The currently executing thread. This is the same as TThread.Current.
    ///    Please use TThread.Current, which is more clear and less redundant.
    /// </summary>
    class property CurrentThread: TThread read GetCurrentThread;
    /// <summary>
    ///    The number of processor cores on which this application is running. This will include virtual
    ///    "Hyper-threading" cores on many modern Intel CPUs. It is ultimately based on what the underlying
    ///    operating system reports.
    /// </summary>
    class property ProcessorCount: Integer read FProcessorCount;
    /// <summary>
    ///    Simple Boolean property to quickly determine wether running on a single CPU based system.
    /// </summary>
    class property IsSingleProcessor: Boolean read GetIsSingleProcessor;
    /// <summary>
    ///    Event handler, which is called before each Synchronize or Queue call.
    /// </summary>
    class property OnSynchronize: TOnSynchronizeProc read FOnSynchronize write FOnSynchronize;
  end;

慢慢开始,我的需求很简单,从Timer改为Thread
第一步、启动线程优雅的执行耗时功能
第二部、启动线程池,让低配的硬件发光发热。
第三步、“论旧举杯先下泪,伤离临水更登楼。”

先去研究下这两段代码

无具体内容附送一段刚D11图片处理的代码:

1、引用单元

interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Mask, Vcl.ExtCtrls,
  IdTCPConnection, IdTCPClient, IdHTTP, IdBaseComponent, IdComponent,
  IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL,
  HtmlParserEx, Vcl.ComCtrls,Winapi.Wincodec;
implementation
uses IdURI,Winapi.UrlMon,Jpeg,inifiles,RegularExpressions,Masks;

2、调用过程

procedure TForm1.Button1Click(Sender: TObject);
var I:Integer;
    s:String;
    SaveToFileName,sTitle,reFileName :String;
begin
    SaveToFileName:=Trim(edtTitle.Text);
    if chbxDownAll.Checked then
    begin
        for I := 0 to scMainTree.Items.Count-1 do
        begin
            if doFind( 0, scMainTree.Items[I] ) then
            begin
                if doWownCurrent(reFileName) then
                begin
                    C_FormatPicture_Fix( reFileName,FWorkPath+trim(edtSubDir.Text)+'\',SaveToFileName, 800, 320,0 );
                end;

                if not chbxDownAll.Checked then
                Break;
            end;
        end;
    end
    else
    begin
        //编辑图片
        if doWownCurrent(reFileName) then
        begin
            C_FormatPicture_Fix( reFileName,FWorkPath+trim(edtSubDir.Text)+'\',SaveToFileName, 800, 320,100 );
            btnFindClick(nil);
        end;
    end;
end;

调试代码

3、实现单元引用

4、代码

// 优先缩放到固定高度,不满足缩放到宽度
function TForm1.C_FormatPicture_Fix(reFileName: String;SavePath:String;SaveToFileName:String;DestWidth,DestHeight:integer;ACompressionQuality:word): Boolean;
var w: TWICImage;
    nWIF: IWICImagingFactory;
    nWIS: IWICBitmapScaler;
    j: TJPEGImage;
    d:TBitmap;
    cmode:Integer;
begin
   Result:=False;
   Try
   w:= TWICImage.Create;
   if not FileExists(reFilename) then Exit;
   w.LoadFromFile(reFilename);
   if ( w.Height < DestHeight ) and ( w.Width < DestWidth ) then Exit;
   //放缩模糊
   //放缩到 DestHeight
   nWIF := w.ImagingFactory;
   nWIF.CreateBitmapScaler(nWIS);
   nWIS.Initialize(w.Handle, round( w.Width*DestHeight / w.Height ), DestHeight , WICBitmapInterpolationModeFant);
   w.Handle := IWICBitmap(nWIS);  nWIS := nil;  nWIF := nil;
   //高度满足
   if (w.width >= DestWidth) then
   begin
        cMode:=1;
        result:=true;
   end
   else
   begin
       //w.LoadFromFile(reFilename); 放缩到宽度
       nWIS := nil;  nWIF := nil;
       nWIF := w.ImagingFactory;
       nWIF.CreateBitmapScaler(nWIS);
       nWIS.Initialize(w.Handle, DestWidth, round( w.Height*DestWidth / w.Width ) , WICBitmapInterpolationModeFant);
       w.Handle := IWICBitmap(nWIS);  nWIS := nil;  nWIF := nil;
       if (w.Height > DestHeight) then
       begin
            cMode:=2;
            Result:=true;
       end;
   end;
   if not Result then Exit;
   Result:=False;

   //Result:=True; cMode:=1;
   //w.SaveToFile(ExtractFilePath(refilename)+'_TTTTT_'+ExtractFileName(refilename)+'.jpg');

   j:= TJPEGImage.Create;
   j.Assign(w);

   d:= TBitmap.Create;
   d.Width:=DestWidth;
   d.Height:=DestHeight;
   if cMode=1 then
       //固定宽度
       d.Canvas.CopyRect(Rect(0,0,DestWidth,DestHeight),j.Canvas,
            Rect(  round( (j.Width-DestWidth) / 2)  , 0, DestWidth,DestHeight))
   else //固定高度
       d.Canvas.CopyRect(Rect(0,0,DestWidth,DestHeight),j.Canvas,
            Rect(  0  ,round( (j.Height-DestHeight) / 2),DestWidth,DestHeight));

   j.Assign(d);
   if ACompressionQuality in [1..100] then
   begin
    j.CompressionQuality := 100;//PressQuality;
    j.Compress;
   end;

   j.SaveToFile ( SavePath+'_M_'+SaveToFileName+'.jpg' );

   Result:=True;
   Finally
     if assigned(w) then FreeAndNil(w);
     if assigned(j) then FreeAndNil(j);
     if assigned(d) then FreeAndNil(d);
   End;
end;

简单裁剪,穷人需要小体积图,懂得点赞。

说明:网络放缩部分参考自网络。

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

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

相关文章

第1节:vue cesium 概述(含网站地址+视频)

在开始介绍vue cesium之前&#xff0c;我们先聊聊cesiumjs&#xff0c;如果你对这块内容比较熟悉&#xff0c;可以直接跳过这节内容。 cesiumJS 简介 官方网址&#xff1a;https://cesium.com/platform/cesiumjs/ CesiumJS 是一个开源 JavaScript 库&#xff0c;主要用于基于…

Linux之理解文件系统——文件的管理

文章目录 前言一、磁盘1.磁盘的物理结构2.磁盘的存储结构3.磁盘的逻辑结构 二、文件系统与inode1.文件在磁盘中是如何存储的&#xff1f;2.对文件进行操作 三、软硬链接1.软链接创建软链接&#xff1a;inode删除软链接&#xff1a;软链接的作用&#xff1a; 2.硬链接创建硬链接…

chatgpt赋能python:Python另存为对话框:如何在Python中创建一个另存为对话框

Python 另存为对话框&#xff1a;如何在Python中创建一个另存为对话框 如果你是一名 Python 开发者&#xff0c;你可能会常常需要为你的应用程序添加一个另存为对话框。这个对话框使用户可以将他们的数据保存为一个新的文件&#xff0c;而不是覆盖原始文件。然而&#xff0c;很…

【JavaEE】Tomcat-Servelet第一个helloworld程序

Tomcat & Servelet第一个程序helloworld&#xff01; 文章目录 JavaEE & Tomcat & 第一个Servelet程序1. HTTP服务器 - Tomcat1.1 Tomcat的目录结构&#xff1a;1.2 启动Tomcat1.3 Tomcat的优点 2. Servelet框架2.1 创建Maven项目2.2 引入依赖2.3 创建目录2.4 写代…

【Java】wait和notify方法

wait方法wait()和join()的区别wait()和sleep()的区别notify()和notifyAll()实例 wait()和notify()方法都是Object类中的方法。由于每个类都会继承Object类&#xff0c;所以每个对象中都会包含这些方法。 wait方法 wait() 是让线程等待一段时间&#xff0c;死等。对应到线程的…

Linux账号管理与ACL权限设定(一)

Linux的账号与群组 Linux系统中&#xff0c;关于账号和群组&#xff0c;实际记录的是UID和GID的数字&#xff1b; 关于账号有两个非常重要的文件&#xff1a;/etc/passwd 和 /etc/shadow &#xff1b; /etc/passwd 文件结构&#xff1a; 账号名称&#xff1a;密码&#xff…

chatgpt赋能python:Python中另起一行输出的方法

Python中另起一行输出的方法 在Python编程中&#xff0c;我们需要经常输出内容到控制台或者文件中。而有时候&#xff0c;我们可能需要将输出的内容另起一行来符合排版或格式要求。这篇文章将介绍Python中另起一行输出的方法。 使用print函数 Python中最简单的输出方法就是使…

阵列信号处理笔记(1):预备知识、阵列流形、波数-频率响应

阵列信号处理笔记&#xff08;1&#xff09; 文章目录 阵列信号处理笔记&#xff08;1&#xff09;预备知识从延时到阵列流形矢量频率波数响应 预备知识 如图所示的球坐标系中&#xff0c;任意一阵元的位置可以用 ( r , ϕ , θ ) (r,\phi,\theta) (r,ϕ,θ)唯一表示&#xff…

前端045_单点登录SSO_实现流程

单点登录SSO_实现流程 1、背景2、基于同域下 Cookie 实现 SSO1、背景 在企业发展初期,企业使用的系统很少,通常一个或者两个,每个系统都有自己的登录模块,运营人员每天用自己的账号登录,很方便。 但随着企业的发展,用到的系统随之增多,运营人员在操作不同的系统时,需要…

Linux命令(28)之locate

Linux命令之locate 1.locate介绍 linux命令locate用于查找文件所在位置&#xff0c;与which、whereis命令类似&#xff0c;locate命令将会在预先建立好的档案数据库中查询文件。 locate档案数据库路径&#xff1a;/var/lib/mlocate locate档案数据库名称&#xff1a;mlocat…

SpringBoot之Transactional事务

目录 一、事务管理方式二、事务提交方式三、事务隔离级别四、事务传播行为1、Propagation.REQUIRED2、Propagation.SUPPORTS3、Propagation.MANDATORY4、Propagation.REQUIRES_NEW5、Propagation.NOT_SUPPORTED6、Propagation.NEVER7、Propagation.NESTED 五、事务回滚六、只读…

前后端分离项目之登录页面(前后端请求、响应和连接数据库)

目录 一、前端登录发起请求 二、后端请求接收 三、连接数据库 四、后端响应 五、前端处理 六、在前端验证用户是否登录 七、web会话跟踪 八、请求拦截器和响应拦截器 本文Vue-cli前端项目基于文章&#xff1a; Vue-cli搭建项目(包含Node.js安装和ElementUI安装)_小俱的…

2. requests.get()函数访问网页(小白入门)

2. requests.get()函数访问网页(小白入门) 文章目录 2. requests.get()函数访问网页(小白入门)1. 人工访问网页2. 爬虫第一步&#xff1a;发起网络请求3. requests库的安装4. requests.get()函数&#xff1a;发送网络请求5. 代码解析1. 导入库的语法2. 指定网址3. 发送请求4. 输…

chatgpt赋能python:Python取消撤销——让你的代码更加高效

Python取消撤销——让你的代码更加高效 在Python编程的过程中&#xff0c;经常会出现需要撤销操作的场景。但是&#xff0c;在一些复杂的代码编辑器中&#xff0c;常规的CtrlZ撤销操作可能无法满足你对代码精度的要求。为此&#xff0c;Python取消撤销就应运而生。 Python取消…

多变量系统的最小二乘辨识问题的推导以及matlab仿真

1.单输入单输出情况的推导;2.两输入两输出情况的推导,并进行matlab仿真以及完成仿真报告。 多变量系统的最小二乘辨识问题是确定一个线性多输入多输出(MIMO)系统的未知参数,使得该系统能够以最佳方式近似给定输入和输出之间的关系。在本例中,我们将展示单输入单输出(SIS…

软件外包开发的测试用例

软件测试用例是一组详细的步骤、输入数据、预期结果和实际结果&#xff0c;用于验证软件是否满足特定需求或功能。编写测试用例的目的是确保软件的质量和性能。今天和大家分享编写软件测试用例的一般步骤&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;…

解决record on line 2: wrong number of fields

背景 基于"encoding/csv"库解析。 共解析多个文档&#xff0c;只有这一个解析有问题&#xff0c;所用代码一致&#xff0c;进行比较后 发现该文档和其它文档不同&#xff0c;其它文档是第一行就是列名&#xff0c;下面都是数据&#xff1b; 而这个文档前两行有数据且…

k8s部署Elasticsearch集群+Kibana方案--开启X-Pack 安全认证

前言 本文中使用StatefulSet 方式部署 Elasticsearch 集群&#xff0c;并且开启X-Pack 安全认证&#xff0c;存储使用的是NFS&#xff0c;属于一个初学者自己探索的方案&#xff0c;如果有比较好的方案&#xff0c;还请不吝评论赐教。 版本说明&#xff1a; Kubernetes v1.25…

微信小程序uniapp医患管理系统预约挂号就诊处方满意评价系统

从系统开发环境、系统目标、设计流程、功能设计等几个方面对系统进行了系统设计。开发出本医患关系管理系统&#xff0c;主要实现了管理员后端&#xff1b;首页、个人中心、用户管理、医生管理、医生信息管理、患者信息管理、预约就诊管理、就诊信息管理、投诉管理、投诉反馈管…

【走进Linux的世界】Linux---基本指令(2)

个人主页&#xff1a;平行线也会相交 欢迎 点赞&#x1f44d; 收藏✨ 留言✉ 加关注&#x1f493;本文由 平行线也会相交 原创 收录于专栏【Linux专栏】&#x1f388; 本专栏旨在分享学习Linux的一点学习心得&#xff0c;欢迎大家在评论区讨论&#x1f48c; 目录 ls *man指令小…