Python 语言特性5

一天一个语言特性更新

数据类型

Number     [数字]
String     [字符串]
List       [列表]
Tuple      [元组]
Set        [集合]
Dictionary [字典]

不可变数据类型

Number     [数字]
String     [字符串]
Tuple      [元组]

可变数据类型

List       [列表]
Set        [集合]
Dictionary [字典]

数据结构

list       [列表]    [10, 20, 30]
tuple      [元组]    (10, 20, 30)
set        [集合]    {10, 20, 30}
dict       [字典]    {'a': 10, 'b': 20}

变量定义

var1 = 18
var2 = 'lr'
var3 = [10, 20, 30]
var4 = (10, 20, 30)
var5 = set([10, 20, 30])
var6 = {'a': 10, 'b': 20}

输入输出

name = input('input your name: ')
print('hello')
print('your name is {}'.format(name))

运算符

算术运算符

+    [加]
-    [减]
*    [乘]
/    [除]
%    [取模]
**   [幂]
//   [取整除]

比较运算符

==   [等于]
>    [大于]
<    [小于]
>=   [大于等于]
<=   [小于等于]

赋值运算符

=    [简单赋值]
+=   [加法赋值]
-=   [减法赋值]
*=   [乘法赋值]
/=   [除法赋值]
%=   [取模赋值]
**   [幂赋值]
//=  [取整除赋值]

位运算符

&    [按位与运算]
|    [按位或运算]
^    [按位异或运算]
~    [按位取反运算]
<<   [左移动运算]
>>   [右移动运算]

逻辑运行符

and  [布尔"与"]
or   [布尔"或"]
not  [布尔"非" ]

成员运行符

in     [在指定的序列中]
not in [不在指定的序列中]

身份运算符

is     [判断两个标识符是否引用自一个对象]
is not [判断两个标识符是不是引用自不同对象]

posted @ 2019-08-22 09:14 lr.cool 阅读(...) 评论(...) 编辑 收藏