为了账号安全,请及时绑定邮箱和手机立即绑定

请问hello跑到哪里去了

temp3='Life is {1},you need {2}.'

result3=temp3.format('hello','short','python')

print(result3)


#这个程序里打印的hello跑到哪里去了?

正在回答

1 回答

hello 对应 {0},short 对应 {1},python 对应 {2}。

hello 对应 {0},short 对应 {1}, python 对应 {2}

你 temp3 里没有 {0},自然就不会打印 hello,建议改成:

temp3 = '{0}! Life is {1}, you need {2}'
result3 = temp3.format('hello', 'short', 'python')
print(result3)


1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Python3 入门教程(新版)
  • 参与学习       147778    人
  • 解答问题       1054    个

python3入门教程,让你快速入门并能编写简单的Python程序

进入课程

请问hello跑到哪里去了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信