问答详情
源自:3-7 Python的字符串format

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

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

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)


提问者:the_tops 2021-01-08 16:13

个回答

  • 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)