2016-11-22 67 views
-2

我想返回Col('red','blue',10)但我总是收到'Col(red, blue, 10)'引号已关闭。返回正确的字符串格式

需要这样做使用的格式:

return 'Col(%s, %s, %d"%(col1,col2,total)' 

回答

1
>>> print "Col('%s', '%s', %d)" % ('red', 'blue', 10) 
Col('red', 'blue', 10) 
+0

应该只是上校( '红', '蓝',20),没有结束引号! – Wanderer

+0

我试图使用repr(“Col('%s','%s',%d)”%('red','blue',10))返回Col('red','blue', 10)。这次。有什么建议么。 – Wanderer

+0

我不明白。 repr(“Col('%s','%s',%d)”%('red','blue',10))已经返回你想要的东西... – Benjamin