1. Format string
% in python is the operation of placing other variables into specific positions of the string to generate a new string. , for example
#This code first defines a variable named n with the content Aki. Then there is a %s in the string below, which means "this will be replaced with a new string". The replacement content is placed after the % at the end of the string, which is the n. So eventually this string will become My name is Aki.
The % in the string will be followed by a letter, which represents the type of variable used for replacement. For example, %d means that the variable you will replace here is an integer, and %s represents an String.
2. Modulo operation
The so-called modulo operation is to calculate the remainder after dividing two numbers, and the symbol is %. For example, a % b is the remainder of dividing a by b.
Related learning recommendations: python tutorial
The above is the detailed content of What does % in python language mean?. For more information, please follow other related articles on the PHP Chinese website!