Home  >  Article  >  Backend Development  >  Python variables and data types

Python variables and data types

黄舟
黄舟Original
2016-12-16 11:41:401694browse

Hexadecimal is represented by 0x prefix and 0-9 a-f

A string is any text enclosed in '' or ""

A Boolean value has only two values ​​​​True and False

Boolean values ​​can be operated with and or not

The null value is a special value in Python, represented by None. None cannot be understood as 0, because 0 is meaningful, and None is a special null value

The PRint statement can input specified text to the screen

The print statement can also keep up with multiple strings

Python comments start with #, and the following text until the end of the line is considered a comment

Some code you don’t want to run, but you don’t want to delete it, you can use comments to temporarily block it

Equal sign = is an assignment statement , you can assign any data type to a variable. The same variable can be assigned repeatedly, and it can be a variable of different types. It cannot be equivalent to the mathematical equal sign ==

Strings contain both ' and ". Strings need to be To escape, insert one in front of it to escape

Commonly used escape characters: not included in the content of the string n represents a newline t represents a tab character \ represents the character itself

Add a in front of the string The prefix r indicates that this is a raw string, and the characters inside do not need to be escaped. However, the r'...' notation cannot represent multi-line strings, nor can it represent strings containing 'and'. If you want to represent a multi-line string, you can use '''...''' to express it. You can also add r in front of the multi-line string to turn this multi-line string into a raw string, r''' ...'''

unicode string is used to input Chinese, u'', ur'''...'''

If you encounter UnicodeDecodeError, add a comment to the first line # -*- coding: utf-8 -*-, then use Notepad++ to save as... and select UTF-8 format to save

The above is the content of Python variables and data types. For more related articles, please pay attention to the PHP Chinese website (www.php.cn) !


Statement:
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