Skip to content

Latest commit

 

History

History
116 lines (71 loc) · 1.55 KB

File metadata and controls

116 lines (71 loc) · 1.55 KB

数据类型

变量类型

包括哪些类型?

str
int
float
bool
byte
list
tuple
set
dict

自定义类型,类

字符串

just_name = 'nicyou'

name = "nicyou"

msg = "hello,i love fanfan~"


message = '''
this is long message
very long message
'''
  1. ''' 保留格式
  2. 在Python中使用单引号或双引号是没有区别的,都可以用来表示一个字符串

字符串中常用转义

\n 换行
\t tab
\r 回车
\"
\'
\\

字符串使用r特性

20200126_204726_92

整型

property = 10000000000

20200126_204857_24

布尔类型

20200126_205041_59

byte字节类型

  • 字符串前含b表示字节类型

20200126_205237_59

20200126_205432_27

list列表

  • [] 数学中称为中括号,而编程中称为中括号

20200126_210542_30

20200126_211233_56

tuple元组

  • 放在小括号
scores = (1311, 2313, 3123, 4, 5, 69, 79, 8, 9)
print(scores, type(scores))

set集合

scores = {1311, 2313, 3123, 9, 9, 9, 94, 5, 69, 79, 8, 9}
print(scores, type(scores))  # 不允许重复类型

dict字典

20200127_085738_60

scores = {'hello': 100, 'hi': 200}
print(scores, type(scores))
  • 集合底层使用了字典来实现,集合就是特殊的字典

20200127_090321_70