Python入门的36个例子——07 运算符和表达式
2009-09-12 01:23
531 查看
# 007 # 得到商的整数部分 print 9 // 4 # 得到除法的余数 print 9 % 4 # 乘幂 print 2 ** 10 # 布尔运算 # 非 print not True print not False # 与 print True and False print True and True # 或 print False or False print True or True # 聪明的Python知道何时自动添加空格 str1 = 'part1' str2 = 'part2' str3 = 'part3' print str1,str2,str3 # 会自动添加空格 print str1 + str2 + str3 # 不会自动添加空格
output:
1 2 3 4 5 6 7 8 9 10 11 | 2 1 1024 False True False True False True part1 part2 part3 part1part2part3 |
相关文章推荐
- Python入门的36个例子——01 我见过的最容易实现的“Hello World!”
- Python入门的36个例子——09 While —— 怎么老是你
- Python入门的36个例子——17 Return
- Python入门的36个例子 之 22 -> Sequences —— 统一的访问方式以及负索引
- Python入门的36个例子 之 30 -> OOP – 初始化
- Python入门的36个例子——02 Help! —— 如何获取帮助
- Python入门的36个例子——10 For —— “计数器”与“遍历器”
- Python入门的36个例子 之 23 -> Objects and References —— 复制引用还是复制实体对象
- Python入门的36个例子 之 31 -> OOP – 属于类的变量和属于对象的变量
- Python入门的36个例子——11 Break —— 终结者
- Python入门的36个例子 之 24 -> 再说说String
- Python入门的36个例子 之 32 -> OOP – Inheritance 继承
- Python入门的36个例子——03 Python 中的数“只有”四种类型
- Python入门的36个例子——12 Continue —— 路上的跳板(躲过一劫)
- Python入门的36个例子 之 25 -> Console In File Out
- Python入门的36个例子 之 33 -> try – 异常是不可避免的,关键是怎样处理
- Python入门的36个例子——04 优雅的字符串
- Python入门的36个例子——13 Function(def)—— 使功能模块化的好方法
- Python入门的36个例子 之 18 -> Modules —— 将它们放到不同的文件里
- Python入门的36个例子 之 26 -> File In Console Out