print("hello {leon}".format(leon="world!")) #format 是一个格式化字符穿的方法。 print("hello {0} i am {1}".format("tom","leon")) print("hello {} i am {}".format("tom","leon")) username = 'leon' #定义username print("welcome user {name} login ... ".format(name=username)) #引用username
打印结果:
C:Python36python.exe H:/leon/day1/input.py
hello world!
hello tom i am leon
hello tom i am leon
welcome user leon login ...
Process finished with exit code 0