python语法学习
2016-02-16 00:12
405 查看
1.整除与幂运算
>>> 5.6//2
2.0
>>> 2**3
8
>>>
2.位移与异或算法
>>> 1<<1
2
>>> 1>>1
0
>>> 1^2
3.字符串
>>> str="abcde"
>>> str[1:4]
'bcd'
>>> str[2:]
'cde'
>>> str[::1] //表示一步一取
'abcde'
>>>
3
>>> 2^3
1
>>> str[-1]
'e'
>>> str*2
'abcdeabcde'
>>> "c" in str
True
>>>
4.元组定义
>>> t=("a","b")
>>> t
('a', 'b')
>>> t[0]
'a'
>>>
>>> 5.6//2
2.0
>>> 2**3
8
>>>
2.位移与异或算法
>>> 1<<1
2
>>> 1>>1
0
>>> 1^2
3.字符串
>>> str="abcde"
>>> str[1:4]
'bcd'
>>> str[2:]
'cde'
>>> str[::1] //表示一步一取
'abcde'
>>>
3
>>> 2^3
1
>>> str[-1]
'e'
>>> str*2
'abcdeabcde'
>>> "c" in str
True
>>>
4.元组定义
>>> t=("a","b")
>>> t
('a', 'b')
>>> t[0]
'a'
>>>
相关文章推荐
- 深入解读Python解析XML的几种方式
- bpython 功能强大的Python shell
- 十条建议帮你提高Python编程效率
- 轻松实现python搭建微信公众平台
- python实现红包裂变算法
- Python实现快速排序和插入排序算法及自定义排序的示例
- Python的GUI框架PySide的安装配置教程
- Python:__slots__用法
- 转 python常用代码
- python学习day day up
- 非常全面到位的介绍与源代码地址 :Python 网页爬虫 & 文本处理 & 科学计算 & 机器学习 & 数据挖掘兵器谱
- python实现快速排序
- leetcode 238. Product of Array Except Self (Python版)
- leetcode 238. Product of Array Except Self (Python版)
- 鼠标自动点击 python版
- python中的定时任务
- python模块的打包setuptools
- python连接数据库
- python排序-堆排序
- Python 基础——set