【发布时间】:2018-02-10 05:33:25
【问题描述】:
我写的代码:
def ball(f):
py_ball = f * 5
u_ball = py_ball / 10
return py_ball, u_ball
print("py ball: {}, u ball: {}".format(ball(100)))
当我使用str.format 时,它会抛出异常:
但如果我使用% 格式:
print("py ball: %d, u ball: %d" % ball(100))
它工作得很好并产生:
py ball: 500, u ball: 50
【问题讨论】:
-
使用
*ball(100)解压返回值
标签: python python-3.x string-formatting