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脚本。

博客介绍了利用Delphi执行Python脚本的方法。先设置Python安装路径和要执行的脚本路径,将二者组合成命令行字符串,再把该字符串赋值给DosCommand1的CommandLine属性,最后启动进程以执行Python脚本。
1172

被折叠的 条评论
为什么被折叠?



