我正在尝试使用 python 3 中的 subprocess.Popen 功能从另一个脚本(scriptB)中使用 python 2 (例如 scriptA) 调用脚本
我希望调用的脚本实现了一个 argparse 方法,该方法需要两个参数,如下所示:ScriptA(需要 python 2):
def get_argument_parser():
'''
'''
import argparse
parser = argparse.ArgumentParser("Get the args")
parser.add_argument("-arg1", "--arg1",required = True,
help = "First Argument")
parser.add_argument("-arg2", "--arg2",required = True,
help = "Second Argument")
return parser
Run Code Online (Sandbox Code Playgroud)
现在,我使用子进程调用上述脚本,如下所示: ScriptB:
value1 = "Some value"
value2 = "Some other value"
subprocess.Popen(["C:\\Python27\\python.exe ", ScriptAPATH, " -arg1 " , value1, " -arg2 ", value2],shell = True, stdout = subprocess.PIPE)
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个错误: error: argument -arg1/--arg1 is required
接下来我尝试的是将 …
我正在使用plotly JS创建一个简单的折线图.代码如下所示:
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
};
var layout = {
xaxis:{
title:"X-Axis",
tickangle:45,
rangemode:'nonnegative',
autorange:true,
exponentformat: "none"
},
yaxis:{
title: "Time",
tickangle:45,
rangemode:'nonnegative',
autorange:false
}
}
Plotly.newPlot(myDiv,[trace1],layout);
Run Code Online (Sandbox Code Playgroud)
现在我想在图表上创建一条水平线,与x轴平行,我想跨越整个图形.为此,我在布局中添加了"形状",如下所示:
var layout = {
xaxis:{
title:"X_Axis",
tickangle:45,
rangemode:'nonnegative',
autorange:true,
exponentformat: "none"
},
yaxis:{
title: "Time",
tickangle:45,
rangemode:'nonnegative',
autorange:false
},
shapes: [
{
type: 'line',
x0: 2,
y0: 12.0,
x1: 3,
y1: 12.0,
line:{
color: 'rgb(255, 0, 0)',
width: 4, …Run Code Online (Sandbox Code Playgroud) 我创建了一个简单的绘图折线图,如下所示:
var trace1 = {
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
};
var layout = {
xaxis:{
title:"x-axis",
tickangle:45,
rangemode:'nonnegative',
autorange:true,
exponentformat: "none"
},
yaxis:{
title: "Time",
tickangle:45,
rangemode:'nonnegative',
range:[0,20],
autorange: false
},
shapes: [
{
type: 'line',
xref: 'paper',
x0: 0,
y0: threshold1,
x1: 1,
y1: threshold1,
line:{
color: 'rgb(255, 0, 0)',
width: 2,
dash:'dot'
},
},
{
type: 'line',
xref: 'paper',
x0: 0,
y0: threshold2,
x1: 1,
y1: threshold2,
line:{
color: 'rgb(0, …Run Code Online (Sandbox Code Playgroud)