procedure TForm1.Button6Click(Sender: TObject);
var
PythonPath,CommandLine:string;
begin
PythonPath:= 'cmd.exe /c C:\Users\86182\AppData\Local\Programs\Python\Python310\python.exe';
CommandLine:='C:\pythoncode\new\copypdfsaveas.py' ;
DosCommand1.CommandLine := PythonPath + ' ' + CommandLine;
// 启动进程
DosCommand1.Execute;
end;
C:\delphisource\mytools\mynewtools\main.pas
- 设置Python的安装路径和要执行的Python脚本路径。
- 将Python的安装路径和脚本路径组合成一个命令行字符串。
- 将命令行字符串赋值给DosCommand1的CommandLine属性。
- 启动进程,执行Python脚本。