将参数(文件)从python脚本传递到laravel artisan命令

2024-06-16 11:30:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我想将两个文件从python脚本传递到laravel artisan命令,即我的python脚本:

import subprocess

file1 = 'C:\\Users\\MyFolder\\Mybook.pdf';
file2 = 'C:\\Users\\MyFolder\\Myaudio.mp3';

subprocess.call("php C:\\xampp\\htdocs\\project\\artisan zip " + file1 +' '+ file2 )

我的命令类:

<?php

class ZipFiles extends Command
{
    protected $signature = 'zip {file1} {file2}';

    protected $description = 'zip files';

    public function handle()
    {
        Log::info($this->argument('file1'));

        Log::info($this->argument('file2'));
    }
}

但我得到了这个错误:

Too many arguments to "zip" command, expected arguments "file1" "file2".


Tags: 命令info脚本logzipthisargumentusers