#本文仅为个人学习过程的整理和记录, if there is a blog from others, the site extracts the content, I will clearly mark, if there is infringement, please contact me, I will be deleted in the first time.
The information is compiled from (1) Liaoche's Python tutorial http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000
(2) Concise python tutorial http://woodpecker.org.cn/abyteofpython_cn/chinese/
Four. Python data type
The main data types in Python are: numbers, strings, lists, tuples, dictionaries
(1) Number
Shaping (int)
int denotes range-2,147,483,648 to 2,147,483,647
>>> num1=123
>>> Type (123)
<class ' int ' >
>>> type (NUM1)
<class ' int ' >
Long integer type
#长整型数据存在于Python2. x version, after the 3.X version, there is now only one integral type--int, but it behaves like 2. X version of Long
Long can almost say that any large integer can be stored.
To differentiate between integers and long integers, you need to add L or lowercase l after an integer.
>>> num2=999999999999999999999999999
>>> type (num2)
<class ' int ' >
>>> num3=3l
Syntaxerror:invalid syntax
Floating point Type
>>> num4=1
>>> type (NUM4)
<class ' int ' >
>>> num5=1.0
>>> type (NUM5)
<class ' float ' >
Plural type
Python provides inline support for complex numbers
>>> num6=1.23j
>>> type (NUM6)
<class ' Complex ' >
>>> NUM6
1.23j
>>> Print (NUM6)
1.23j
(2) string
A set of quotation marks that can include a set of numbers, letters, symbols (non-special system symbols).
Strval= ' Just test. '
Strval= "Just test."
Strval= "Just test."
#三引号 (docstring) is used to make strings. (note, doc data)
>>> str1= ' Hello world! '
>>> type (STR1)
<class ' str ' >
>>> str2= "Hello world!"
>>> type (STR2)
<class ' str ' >
>>> str3= ' Hello world '
>>> type (STR3)
<class ' str ' >
>>> str4= ' What's up? '
Syntaxerror:invalid syntax
>>> str5= "What's Up?"
>>> type (STR5)
<class ' str ' >
>>> str6= ' He said: "What's Up?" ‘‘‘
>>> type (STR6)
<class ' str ' >
>>> str7= "What" s\ "up?\" "
>>> type (STR7)
<class ' str ' >
>>> STR7
' What\ ' "Up?"
>>> mail= ' Tom: \ n hello! \ n I am Jerry. '
>>> Mail
' Tom: \ n hello! \ n I am Jerry. '
>>> Print (mail)
Tom:
Hello!
I am Jerry.
>>> mail= ' Tom:
I am Jerry.
Come out to play.
>>> Mail
' Tom: \n\ti am jerry.\n\tcome out to play. '
>>> Print (mail)
Tom:
I am Jerry.
Come out to play.
Summary: Strings, lists, and tuples are called sequence type data.
Use an index to take a value from a string (value)
>>> str9= ' Asdfghj '
>>> Str9[1]
' s '
>>> Str9[0]+str9[1]
' As '
Slice (start value, end value, step value #起始会包括, end truncated )
>>> str9= ' Asdfghj '
>>> Str9[1]
' s '
>>> Str9[0]+str9[1]
' As '
>>>
>>> Str9[1:4]
' SDF '
>>> Str9[:4]
' Asdf '
>>> Str9[4:]
' Ghj '
>>> str9[::]
' Asdfghj '
>>> Str9[::3]
' AFJ '
>>> Str9[-1]
' J '
>>> Str9[-3:-1]
' GH '
>>> Str9[-1:-4]
‘‘
>>> Str9[-1:-4:-1]
' JHG '
>>> Str9[-1:-5:-2]
' JG '
(3)
Python learning log for small y-data type