我正在做一个关于电报上公共汽车时间的项目,但是Python打印以0
结束的小时,而不打印0
,例如10.10
变成10.1
if len(htp) > 0: # if the list contains at least one time
alert3 = "I prossimi pullman sono alle: "
orari_ufficiosi = []
for rfd in htp: # for each timetable
if allhd[allh.index(str(rfd))] != "0": # if the destination stop has that line
orari_ufficiosi.append(rfd)
bot.api.call('sendMessage', {
'chat_id': chat_id,
'text': alert3 + str(",\n ".join(map(str,orari_ufficiosi)))
})
可以看出这个问题
我试过了,我想
format(a,'.2f')
会适合你的需要,或者你从下面选择。下面是一个如何使用的示例:但请注意,它将是一个字符串,我想你将发送一个电报消息,所以这将为你工作
检查此代码:
样本输出:
相关问题 更多 >
编程相关推荐