参考答案不好啊,我感觉还是我这样舒坦!

来源:3-7 Python的字符串format

the_tops

2021-01-08 16:13

为啥要按照参考答案这样来?我这样也可以啊 -------- 

template = '{0}, {1}'

result = template.format('WorldLife is short', 'you need Python .')

print(result)


template = '{w}, {c}'

World = 'WorldLife is short'

you = 'you need Python .'

result1 = template.format(w = World, c = you)

print(result1)


写回答 关注

3回答

  • the_tops
    2021-01-11 09:19:32

    就是打印的几种方式,是用了看的那个知识点.其实没啥

  • 宝慕林2623268
    2021-01-11 09:17:57

    到底什么意思

  • the_tops
    2021-01-08 16:13:55

    template = '{0}, {1}'

    result = template.format('WorldLife is short', 'you need Python .')

    print(result)


    template = '{w}, {c}'

    World = 'WorldLife is short'

    you = 'you need Python .'

    result1 = template.format(w = World, c = you)

    print(result1)


Python3 入门教程(新版)

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

154160 学习 · 1075 问题

查看课程

相似问题