What does % in python language mean?

silencement
Release: 2020-09-18 14:41:05
Original
80087 people have browsed it

What does % in python language mean?

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

What does % in python language mean?

#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.

What does % in python language mean?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!