python3 slice
2015-08-15 21:54
615 查看
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 'spam eggs'
'spam eggs'
>>> 'doesn\'t' #单引号转义
"doesn't"
>>> '"yes",he said .'
'"yes",he said .'
>>> "\"yes,\" he said"
'"yes," he said'
>>> '"Isn\'t," she said'
'"Isn\'t," she said'
>>> print('"Isn\'t," she said')
"Isn't," she said
>>> s = 'First line.\n Second line' #"\n" 意味着新的一行
>>> s
'First line.\n Second line'
>>> print(s)
First line.
Second line
>>> print('c:\some\name') #here \n means newline
c:\some
ame
>>> print(r'c:\some\name')
c:\some\name
>>> print("""\
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
""")
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
>>> # 3 times 'un' ,followed by 'ium'
>>> 3*'un' + 'ium'
'unununium'
>>> 'Py' 'thon'
'Python'
>>> text =('put several strings within parentheses'
'to have them joined together')
>>> text
'put several strings within parenthesesto have them joined together'
>>> word = 'Python3'
>>> word[0]
'P'
>>> word[5]
'n'
>>> word[-1]
'3'
>>> word = 'Python'
>>> word[0]
'P'
.
>>> word[5]
'n'
>>> word[0:2]
'Py'
>>> word[2:5]
'tho'
>>> word[:2]+word[2:]
'Python'
>>> word[:4]+word[4:]
'Python'
>>> word[-2:]
'on'
>>>
Type "copyright", "credits" or "license()" for more information.
>>> 'spam eggs'
'spam eggs'
>>> 'doesn\'t' #单引号转义
"doesn't"
>>> '"yes",he said .'
'"yes",he said .'
>>> "\"yes,\" he said"
'"yes," he said'
>>> '"Isn\'t," she said'
'"Isn\'t," she said'
>>> print('"Isn\'t," she said')
"Isn't," she said
>>> s = 'First line.\n Second line' #"\n" 意味着新的一行
>>> s
'First line.\n Second line'
>>> print(s)
First line.
Second line
>>> print('c:\some\name') #here \n means newline
c:\some
ame
>>> print(r'c:\some\name')
c:\some\name
>>> print("""\
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
""")
Usage: thingy [OPTIONS]
-h Display this usage message
-H hostname Hostname to connect to
>>> # 3 times 'un' ,followed by 'ium'
>>> 3*'un' + 'ium'
'unununium'
>>> 'Py' 'thon'
'Python'
>>> text =('put several strings within parentheses'
'to have them joined together')
>>> text
'put several strings within parenthesesto have them joined together'
>>> word = 'Python3'
>>> word[0]
'P'
>>> word[5]
'n'
>>> word[-1]
'3'
>>> word = 'Python'
>>> word[0]
'P'
.
>>> word[5]
'n'
>>> word[0:2]
'Py'
>>> word[2:5]
'tho'
>>> word[:2]+word[2:]
'Python'
>>> word[:4]+word[4:]
'Python'
>>> word[-2:]
'on'
>>>
相关文章推荐
- Python 学习之Virtualenv
- Python多线程(1)——介绍
- python 机器学习之kNN算法
- Python多线程(2)——线程同步机制
- vijos - P1164曹冲养猪(中国剩余定理 + python)
- Python3 字符串
- Python 3 数值计算
- 用Python 爬虫爬取贴吧图片
- Python编程中常用的12种基础知识总结
- 06 序列:字符串、列表和元组 - 《Python 核心编程》
- python 笔记(一) —— 不要误用 ++i、--i
- 小白Windows7/10 64Bit安装Theano并实现GPU加速(没有MinGw等,详细步骤)
- 树莓派用Python写几个简单程序6_yeelink平台
- 树莓派用Python写几个简单程序4_UART
- 使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务
- 使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务
- 树莓派用Python写几个简单程序3_i2c
- python pandas 如何对一列做四舍五入的操作
- 【Python基础】Python中的协程
- Python 之 glob读取路径下所有文件夹或文件方法