Python3-Basic data types

Integer

  • Definition: a = 125.
  • Python can handle integers of "arbitrary" size including negative numbers.
  • Support binary, octal, decimal, hexadecimal

Distinguish by prefix:

Prefix example Base
0b or 0B a = 0b1010 2
0o or 0O a = 0o12 8
no a = 10 10
0x or 0X a = 0xa 16

Floating point

Three methods defined:

  1.  a = 1.2
  2. b = .4
  3. c = 1.2e-4

type()

We can use the type() function to determine which type the variable is

Numerical addition, subtraction, multiplication and division operations

When the division operation is performed by the / operator, the result of the division must be a floating point number regardless of whether it is divided or not

When an integer is divided by the // operator, the result must be an integer regardless of whether it is divisible or not

The result of adding and subtracting a multiplier of a floating-point number must be a floating-point number

String

definition:

  1. a = 'test'
  2. a = "test"
  3. a = "Chinese"
  4. a =''' contains a double quotation mark (") and a single quotation mark (')''' in a string (you can also add \ escape)

Calculate the length of the string len()

Addition and multiplication of strings

 String formatting

 

The last method requires Python 3.6 or later to be supported.

Boolean

NONE

A null value is no value, not an empty value

a ='' is not called empty, a = None is called empty

Guess you like

Origin blog.csdn.net/u014608280/article/details/98379305