简体   繁体   English

转义序列以解析python中双字符串内的值

[英]escape sequence to parse the value inside double string in python

I have 我有

a=2
b=4

I used 我用了

print 'cubit.cmd("create curve vertex %d %d ") %%(a,b)' %(a,b)

which gives 这使

cubit.cmd("create curve vertex 2 4 ") %(a,b)

but I want to have only the part without % and afterwards. 但我只想保留不包含%的部分,然后再添加。 Like 喜欢

cubit.cmd("create curve vertex 2 4 ")

I want to parse the commands to another software so I must use some variation of escape sequence. 我想将命令解析到另一个软件,因此我必须使用一些转义序列。

Any suggestions? 有什么建议么?

regards 问候

If your expected output is: 如果您的预期输出是:

cubit.cmd("create curve vertex 2 4 ")

...just remove the part afterwards: it's just a string after all. ...然后只删除该部分:毕竟只是一个字符串。

print 'cubit.cmd("create curve vertex %d %d ")' %(a,b)

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

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