Basic knowledge of python syntax

王林
Release: 2019-10-29 18:06:53
Original
11108 people have browsed it

Basic knowledge of python syntax

1. Numeric types and operations

1. Integer types

can be positive or negative, with no limit on the value range

pow(x,y):计算x^y
Copy after login

2. Floating point number type

There is an uncertain mantissa

round(x,d):对x四舍五入,d为小数截取位数
Copy after login

3. Complex number type

2. Numerical operation operator

3. Numerical operation function

4. Representation of string type (consisting of a pair of single quotes or An ordered sequence of characters represented by double quotes)

[M:N:K], slice the string according to the step size K

Special characters: "\b ": Go back "\n": Line feed (the cursor moves to the beginning of the next line) "\r": Carriage return (the cursor moves to the beginning of this line)

5. String processing function

len(x): length str(x): string form corresponding to any type x

chr(x): x is Unicode encoding, return its corresponding character ord (x) : On the contrary

Recommended tutorial: python tutorial

The above is the detailed content of Basic knowledge of python syntax. 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 [email protected]
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!