标签:img orm 四舍五入 整理 打印 mic sep 课堂 进制
tp1 = "i am %s my hobby is alex" % ‘lhf‘ print(tp1)
tp1 = "i am %s my hobby is %s" % (‘lhf‘, ‘dabai‘) print(tp1)
、
tp1 = "i am %s my age is %d" % (‘lhf‘, 11) tp2 = "1 am %s my age is %s" % (‘dabai‘, 12) print(tp1, tp2, sep="\n")
tp1 = "percent %f"% 99.99675854 tp2 = "percent %.3f"% 99.99975854 print(tp1) print(tp2)
tp1 = "percent %.3f%%"% 99.99635854 print(tp1)
tp1 = "i am %(name)s age %(age)d" %{"name": "alex", "age": 18} print(tp1)
tp1 = "i am %(pp).2f" % {"pp": 99.99} print(tp1)
msg = "i am %(name) + 30s my hobby is dabai" % {‘name‘: ‘liu‘} msg2 = "i am \033[42;1m%(name) + 30s\033[0m my hobby is dabai" % {‘name‘: ‘liu‘} print(msg) print(msg2)
tp1 = "i am {} age {} {}".format("alex", 18, "alex") print(tp1)
tp1 = "i am {2} age {1} {0}".format("alex", 18, "dabai") print(tp1)
tp1 = "i am {name} age {age} really {name}".format(name = "alex", age = 18) tp2 = "i am {name} age {age} really {name}".format(**{"name": "alex", "age": 18}) print(tp1) print(tp2)
tp2 = "i am {0[0]} age {0[1]} really {0[2]}".format(["dabai","22","aaa"],[1,2,3]) print(tp2)
tp2 = "i am {:s} age {:d} really {:.2f}".format("dabai", 18, 99.9) print(tp2)
tp2 = "i am {:s} age {:d} really {:.2f}".format(*["dabai", 18, 99.9]) print(tp2)
tp1 = "number: {:b} {:o} {:d},{:x}, {:X}, {:.2%}".format(15, 15, 15, 15,15,15.2341234) print(tp1)
tp1 = "number: {0:b} {0:o} {0:d},{0:x}, {0:X}, {0:.2%}".format(15) print(tp1)
tp1 = "number: {num:b} {num:o} {num:d},{num:x}, {num:X}, {num:.2%}".format(num = 15) print(tp1)
标签:img orm 四舍五入 整理 打印 mic sep 课堂 进制
原文地址:https://www.cnblogs.com/dabai123/p/11007098.html