我刚刚从Google示例代码留言簿中学习Python Webapp2,存储一行文本逗号分隔并显示为格式化字符串。我的问题是用逗号分隔的字符串中有大约11个项目,但Python'%s'%或{}。格式将单行文本返回给我。我试图将文本转换为元组(),它变得更糟糕的分解到每个字符的列表。我错过了什么?字符串格式化python webapp2
for greeting in greetings:
if greeting.author:
self.response.write(
'<b>%s</b> wrote:' % greeting.author.nickname())
else:
self.response.write('Power consumption:')
self.response.write('<blockquote>%s</blockquote>' %
cgi.escape(greeting.content))
self.response.write(count: '{0}'.format(greeting.content.split(',')))
文本:
85327, '2000/0/0', '0:00:00',61.02,76.50,80.16,0.68,0.03,48.91, '二分之二千一百零六/ 6','6 :28:16'count:[u'85327',u''2000/0/0'“,u''0:00:00'”,u'61.02',u'76.50',u'80.16' ,u'0.68' ,u'0.03' ,u'48.91' ,u “的 '2106年2月6日'” U “ '六点28分16秒'”]
留言名称: Login
你到底写? greeting.content中有多个项目? –
你的问题不清楚:你想达到什么目的?预期产出是多少? '问候'声明在哪里? – alfasin