繁体   English   中英

使用python将命令解析到另一个软件接口

[英]Parsing the commands to another software interface using python

我正在使用python生成另一个软件界面的命令列表。 使用命令

sensorik.cmd('list curve')

将把文字

list curve

在该界面中,它列出了该程序中直至该点的所有曲线。 现在我要介绍一个命令循环,这是一个示例

sideset 1  curve 1
sideset 2  curve 2
sideset 3  curve 3

我用了

for curveID in range (1, 4):
print "sideset %d  curve %d" % (curveID, curveID)
sensorik.cmd('print "sideset %d  curve %d" % (curveID, curveID)')
sensorik.cmd('sideset %d  curve %d" % (curveID, curveID)')

但是,这不起作用,并且界面会获取命令

print "sideset %d  curve %d" % (curveID, curveID)

并且它确实在shell提示上打印了所需的文本,但在sensorik.cmd中使用时不会将其解析为软件。 相反,软件会

print "sideset %d  curve %d" % (curveID, curveID)
print "sideset %d  curve %d" % (curveID, curveID)
print "sideset %d  curve %d" % (curveID, curveID)

有什么建议么?

为什么不:

cmd = 'print "sideset %d  curve %d" %% (curveID, curveID)' % (curveID, curveID)
sensorik.cmd( cmd )

您需要%%逃脱百分号作为这里指出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM