Python3 字符串
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'
>>>
Python3 字符串的更多相关文章
- python3字符串
Python3 字符串 Python字符串运算符 + 字符串连接 a + b 输出结果: HelloPython * 重复输出字符串 a*2 输出结果:HelloHello [] 通过索引获取字符串中 ...
- [转]python3字符串与文本处理
转自:python3字符串与文本处理 阅读目录 1.针对任意多的分隔符拆分字符串 2.在字符串的开头或结尾处做文本匹配 3.利用shell通配符做字符串匹配 4.文本模式的匹配和查找 5.查找和替换文 ...
- python3字符串操作
python3字符串操作 x = 'abc' y = 'defgh' print(x + y) #x+y print(x * ) #x*n print(x[]) #x[i] print(y[:-]) ...
- 【2】python3字符串的比较(辨析is与==的区别)
PYTHON3基本数据类型(二.字符串) Python3字符串 ①字符串比较 1.比较字符串是否相同: ==:使用==来比较两个字符串内的value值是否相同 is:比较两个字符串的id值. 2.字符 ...
- python系列四:Python3字符串
#!/usr/bin/python #Python3 字符串#可以截取字符串的一部分并与其他字段拼接var1 = 'Hello World!'print ("已更新字符串 : ", ...
- python3 字符串属性(一)
python3 字符串属性 >>> a='hello world' >>> dir(a) ['__add__', '__class__', '__contains_ ...
- (十四)Python3 字符串格式化
Python3 字符串格式化 字符串的格式化方法分为两种,分别为占位符(%)和format方式.占位符方式在Python2.x中用的比较广泛,随着Python3.x的使用越来越广,format方式使用 ...
- Python3字符串 详解
Python3 字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可. Python 访问字符串中的值 P ...
- [No000078]Python3 字符串操作
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...
- python3 字符串操作相关函数
整理自python基础|菜鸟教程 感谢菜鸟教程提供的优质资源! 1.capitalize() 将字符串的第一个字符转换为大写 实例 以下实例展示了capitalize()方法的实例: #!/usr/b ...
随机推荐
- Lua.LearningLua.5-document-for-luaL_findtable-function
Learning Lua: 5 - Document for luaL_findtable() function 文档中没有找到luaL_findtable()函数的说明,这里尝试补充. LUALIB ...
- zend 汉化
http://jingyan.baidu.com/article/4f34706ecdb566e387b56d05.html
- C# 读写excel 用于导入数据库 批量导入导出excel
给大家介绍一款控件,Aspose.Cells.dll,相当强大,几乎就是excel,支持excel2003,excel2007等格式文件.excel2010以上,没有经过测试,估计也是可以. Aspo ...
- cell跳出动画
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- Yaf零基础学习总结3-Hello Yaf
Yaf零基础学习总结3-Hello Yaf 上一次我们已经学习了如何安装yaf了,准备工作做好了之后我们来开始实际的编码了,码农都知道一个经典的语句就是“Hello World”了,今天我们开始入手Y ...
- linux-3重置root密码
1.首先确认是redhat7 [root@localhost /]# cat /etc/redhat-release 详细步骤: 第1步:开机后在内核上敲击"e". 第2步:在li ...
- 安装SQLSERVER2012遇到的一些问题
安装SQLSERVER2012遇到的一些问题 先到MSDN我告诉你http://msdn.itellyou.cn/下载安装包,我每次都到MSDN我告诉你里下载的,因为那里的安装包保证能用 我的环境是: ...
- 谈谈自己了解的spring.NET的依赖注入
spring.net里实现了控制反转IOC(Inversion of control),也即依赖注入DI(Dependency Injection),以达到解耦的目的,实现模块的组件化.程序 ...
- 大熊君说说JS与设计模式之------状态模式State
一,总体概要 1,笔者浅谈 状态模式,又称状态对象模式(Pattern of Objects for States),状态模式是对象的行为模式. 状态模式主要解决的是当控制一个对象状态的条件表达式过于 ...
- C语言 栈 链式结构 实现
一个C语言链式结构实现的栈 mStack (GCC编译). /** * @brief C语言实现的链式结构类型的栈 * @author wid * @date 2013-10-30 * * @note ...