Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
\n使用javascript执行时出现问题";python-c";_Javascript_Python - Fatal编程技术网

\n使用javascript执行时出现问题";python-c";

\n使用javascript执行时出现问题";python-c";,javascript,python,Javascript,Python,我尝试使用javascript通过“python-c”执行一些python代码。它在Linux中工作, 但我不知道为什么在windows和mac上失败了, 我想这是由于\n\r\n和\r\n之间的差异造成的 所以我想问一下如何解决这个问题 这个项目正在进行中 您可以克隆它并在vscode中运行。您没有收到任何错误消息吗?也许还有更多的信息。在javascript中,我没有得到任何有用的消息 function get_params(command_string,tpp){ var rt =

我尝试使用javascript通过“python-c”执行一些python代码。它在Linux中工作, 但我不知道为什么在windows和mac上失败了, 我想这是由于\n\r\n和\r\n之间的差异造成的

所以我想问一下如何解决这个问题

这个项目正在进行中


您可以克隆它并在vscode中运行。

您没有收到任何错误消息吗?也许还有更多的信息。在javascript中,我没有得到任何有用的消息
function get_params(command_string,tpp){
    var rt = "None"
    // 如果存在->那么取出值并覆盖
    if(command_string.search("->") != -1){
        rt = /->(.*):/.exec(command_string)[1]
        var rep = /\)(\s{0,1}->\s{0,1}.*):/.exec(command_string)[1];
        command_string = command_string.replace(rep, "");
    }
    command_string = command_string.replace(/(^\s*)/g, "");


    var func_name = /^def ([_\da-zA-Z]+)\(.*/.exec(command_string)[1]

    var comon = `python -c "
import inspect
import json
from typing import *
from datetime import *
result = []
${command_string}
    pass
for x in inspect.signature(${func_name}).parameters.values():
    try:
        result.append(dict(name=x.name, annotation=x.annotation.__name__ if x.annotation != inspect._empty else 'Undeclared', default= x.default if x.default != inspect._empty else 'Undeclared')) 
    except Exception:
        result.append(dict(name=x.name, annotation=x.annotation._name if x.annotation != inspect._empty else 'Undeclared', default= x.default if x.default != inspect._empty else 'Undeclared'))
print(json.dumps(result))
"`
    console.log(comon)
    var message = execute(comon).toString();
    return {
        "params":GenarateParamDoc(JSON.parse(message), tpp),
        "rt": rt
}
}