杭州网帮你
python基础数据类型表达式语句运算符内建函数构造函数字符串相关函数
时间:2019-09-08 02:00:18 浏览:120

数据类型:
   不可变的类型:
     bool, int, float, complex, str, tuple, frozenset, bytes(后面会讲)
   可变的数据类型:
     list, dict, set, bytearray(后面会讲)
 值:
   None, False, True

运算符:
 + - * /  // % **
 >  >=  <  <=  ==  !=
 not  and  or
 in, not in
 & | ^
 +(正号) -(负号)

表达式:
 100
 100 + 200
 len([1,2,3]) + max([1,2,3])  # 函数调用是表达式
 print("hello")
 条件表达式: x if x > y else y
 全部的推导式: [x for x in range(5)]
      (列表,字典,集合推导式三种)

语句 statement
 表达式语句:
    print("hello world")
    'hello'
 赋值语句:
   a = 100
   a = b = c = 200
   x, y, z = 100, 200, 300
 if 语句
 while 语句
 for 语句
 break 语句
 continue 语句
 pass 语句
 del 语句


内建函数:
 len(x)
 max(x)
 min(x)
 sum(x)
 any(x)
 all(x)
构造函数:
 bool(x)
 int(x, base=10)
 float(x)
 complex(real=0, image=0)
 str(x)
 list(x)
 tuple(x)
 dict(x)
 set(x)
 frozenset(x)

数字处理函数:
 abs(x)
 round(x)
 pow(x, y,z=0)

字符串相关函数:
 bin(x)
 oct(x)
 hex(x)
 chr(x)
 ord(x)
迭代器相关:
 range(start, stop, step)
 reversed(x)
 sorted(x)
输入输出相关:
 input(x)
 print(...)
详见:
 >>> help(__builtins__)

[上一篇]python函数的参数传递方式
[下一篇]python字典推导式语法说明示例
Copyright 2022 © 93580.com.cn 网帮你

2022 © 版权所有 红花岗区网帮你信息技术工作室

工信部备案号:黔ICP备2024036985号-2

请使用网帮你微信扫码登录