Python and variables and data types and encoding the string

Data types and variables

1: integer; float; string (string, "to represent; there are some escape character);

2: integer and floating-point numbers can be infinite; there is no limit of the number of bits;

3: Boolean values ​​are true and false; Null none; at pl / sql as is null; 

4: Python variable type is not fixed is called dynamic languages;

5: / (float result); // (the result is an integer)% (result is the remainder)

Strings and coding

ASCII-> UNICODE-> UTF-8
English - "Multi-language -" to save the letters footprint;

For encoding a single character, Python provides the ord () function to get the character integer, chr (transcoding function to the corresponding character);

Python data bytes belt type single quotes or double quotes b prefix indicates (on the network and stored on the hard disk is represented by bytes);

To calculate str contains how many characters you can use len () function;

len () function calculates the number of characters of str, if changed bytes, len () function computes the number of bytes;

In Python, using C language and formatting manner consistent, implemented%;

% Operator is used to format string. Within the string, the string is represented by S% Alternatively,% d represents an integer Alternatively, a few%? Placeholder, just behind several variables or a value, the order to the corresponding well. If only one percent ?, parenthesis may be omitted;
format ()
Another method is to use a string formatted string format () method, which in turn replaces the placeholder in the passed string argument;

Published 153 original articles · won praise 15 · Views 150,000 +

Guess you like

Origin blog.csdn.net/beyond911/article/details/104092855