Python 运算符
来源:互联网 发布:mac怎么下载rayfile 编辑:程序博客网 时间:2024/06/15 01:33
Python算术运算符 (**表示幂,//表示除数取整)
以下假设变量a为10,变量b为20:
Python比较运算符(<>表示不等于,与!=相似)
以下假设变量a为10,变量b为20:
Python赋值运算符
以下假设变量a为10,变量b为20:
Python位运算符
按位运算符是把数字看作二进制来进行计算的。Python中的按位运算法则如下:
Python逻辑运算符(and , or, not )
Python语言支持逻辑运算符,以下假设变量a为10,变量b为20:
Python成员运算符(in ,not in)
除了以上的一些运算符之外,Python还支持成员运算符,测试实例中包含了一系列的成员,包括字符串,列表或元组。
#!/usr/bin/pythona = 10b = 20list = [1, 2, 3, 4, 5 ];if ( a in list ): print "Line 1 - a is available in the given list"else: print "Line 1 - a is not available in the given list"if ( b not in list ): print "Line 2 - b is not available in the given list"else: print "Line 2 - b is available in the given list"a = 2if ( a in list ): print "Line 3 - a is available in the given list"else: print "Line 3 - a is not available in the given list"
以上实例输出结果:
Line 1 - a is not available in the given listLine 2 - b is not available in the given listLine 3 - a is available in the given list
Python身份运算符 (id(a)? is , is not 是否是同一个引用)
身份运算符用于比较两个对象的存储单元( 在python 中是定义一个变量时给他赋值,如果这个值在内存已经存在直接赋值)
Python运算符优先级
以下表格列出了从最高到最低优先级的所有运算符:
0 0
- Python 运算符
- Python运算符重载
- Python 的运算符
- python运算符优先级
- python运算符
- python 运算符详解
- Python运算符重载
- Python运算符重载
- python 运算符
- python-DAY2-运算符
- Python 切片运算符
- 运算符-python
- Python中运算符
- python-运算符
- python的运算符
- Python运算符重载
- Python 运算符
- Python运算符重载
- iframe使用
- Python 数据类型转换
- Java反射使用--通知栏回收
- linux shell 中"2>&1"含义
- awk 命令
- Python 运算符
- 聚合物锂电池介绍
- 路由控制和视图转换框架 SPA
- android开发之SharedPreferences工具类
- Eclipse中修改SVN用户名和密码方法
- ajax基础知识,原生态ajax示例,jquery的ajax示例
- JS nodetype返回类型
- git remote
- 精简指令集