
Pycharm练习:

------------------------------------------------------------------------------------------------------------------------------





-------------------------------------------------------------------------------------------------------------------------------------------------------------------



@常用的format格式化 :
1 tpl = "i am {}, age {}, {}".format("seven", 18, 'alex') 2 3 tpl = "i am {}, age {}, {}".format(*["seven", 18, 'alex']) 4 5 tpl = "i am {0}, age {1}, really {0}".format("seven", 18) 6 7 tpl = "i am {0}, age {1}, really {0}".format(*["seven", 18]) 8 9 tpl = "i am {name}, age {age}, really {name}".format(name="seven", age=18) 10 11 tpl = "i am {name}, age {age}, really {name}".format(**{"name": "seven", "age": 18}) 12 13 tpl = "i am {0[0]}, age {0[1]}, really {0[2]}".format([1, 2, 3], [11, 22, 33]) 14 15 tpl = "i am {:s}, age {:d}, money {:f}".format("seven", 18, 88888.1) 16 17 tpl = "i am {:s}, age {:d}".format(*["seven", 18]) 18 19 tpl = "i am {name:s}, age {age:d}".format(name="seven", age=18) 20 21 tpl = "i am {name:s}, age {age:d}".format(**{"name": "seven", "age": 18}) 22 23 tpl = "numbers: {:b},{:o},{:d},{:x},{:X}, {:%}".format(15, 15, 15, 15, 15, 15.87623, 2) 24 25 tpl = "numbers: {:b},{:o},{:d},{:x},{:X}, {:%}".format(15, 15, 15, 15, 15, 15.87623, 2) 26 27 tpl = "numbers: {0:b},{0:o},{0:d},{0:x},{0:X}, {0:%}".format(15) 28 29 tpl = "numbers: {num:b},{num:o},{num:d},{num:x},{num:X}, {num:%}".format(num=15)
浙公网安备 33010602011771号