% character, string plus color, sep separator

msg="percent %.3f%%"%9.998832
print(msg)

Output 9.999% full 5 into a floating point number with f, %% means output a %

msg= " i am %(name)s toke " %{ " name " : " cat " }
 print (msg) 
%s output string name usage is a dictionary

- left-aligned, + right-aligned

Add color \033[43; 1m string such as cat \033[0m

msg="i am \033[43;1m  %(name)-4s \033[0m toke"%{"name":"cat"}
print(msg)

The use of the separator sep is a simplified expression,
 print ( ' i ' , ' am ' , ' cat ' , sep= ' : ' )

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324840154&siteId=291194637