简体   繁体   中英

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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