For example:
test
"Print" it is a% s "%(a)
The result of printing is that it is a test.
2. Look at% as an operation symbol, and find the remainder.
For example:
Modular operation is equivalent to mod, which is to calculate the remainder of division. For example, 5%2 will get 1.
Extended data:
Common operations in% python are %s, %d, %r, etc.
% s,% r and% d indicate that strings are represented by str (), rper () and decimal integer respectively, and %f indicates that the result is floating point.
1, %f floating-point type
Import? mathematics
%a.bf, where a represents the printing length of floating-point number, b represents the precision after decimal point of floating-point number, and %f represents the original value. The default value is 5 digits after the decimal point.
Print? " PI=%f "? %? math.pi
Output:? PI=3. 14 1593
When it is only %9f, it means that the printing length is 9 digits, and the decimal point also occupies one digit, which is not enough to fill the space on the left.
Print? “PI=%9f”? %? math.pi
Output:? PI=_3. 14 1593?
2.%d integer
【python】? View the plain? copy
num= 14
The result of #%d printing is 14.
3.%s string
【python】? View the plain? copy
String= "Hello"
When %s prints, the result is hello.