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 字符串的更多相关文章

  1. python3字符串

    Python3 字符串 Python字符串运算符 + 字符串连接 a + b 输出结果: HelloPython * 重复输出字符串 a*2 输出结果:HelloHello [] 通过索引获取字符串中 ...

  2. [转]python3字符串与文本处理

    转自:python3字符串与文本处理 阅读目录 1.针对任意多的分隔符拆分字符串 2.在字符串的开头或结尾处做文本匹配 3.利用shell通配符做字符串匹配 4.文本模式的匹配和查找 5.查找和替换文 ...

  3. python3字符串操作

    python3字符串操作 x = 'abc' y = 'defgh' print(x + y) #x+y print(x * ) #x*n print(x[]) #x[i] print(y[:-]) ...

  4. 【2】python3字符串的比较(辨析is与==的区别)

    PYTHON3基本数据类型(二.字符串) Python3字符串 ①字符串比较 1.比较字符串是否相同: ==:使用==来比较两个字符串内的value值是否相同 is:比较两个字符串的id值. 2.字符 ...

  5. python系列四:Python3字符串

    #!/usr/bin/python #Python3 字符串#可以截取字符串的一部分并与其他字段拼接var1 = 'Hello World!'print ("已更新字符串 : ", ...

  6. python3 字符串属性(一)

    python3 字符串属性 >>> a='hello world' >>> dir(a) ['__add__', '__class__', '__contains_ ...

  7. (十四)Python3 字符串格式化

    Python3 字符串格式化 字符串的格式化方法分为两种,分别为占位符(%)和format方式.占位符方式在Python2.x中用的比较广泛,随着Python3.x的使用越来越广,format方式使用 ...

  8. Python3字符串 详解

    Python3 字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可. Python 访问字符串中的值 P ...

  9. [No000078]Python3 字符串操作

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...

  10. python3 字符串操作相关函数

    整理自python基础|菜鸟教程 感谢菜鸟教程提供的优质资源! 1.capitalize() 将字符串的第一个字符转换为大写 实例 以下实例展示了capitalize()方法的实例: #!/usr/b ...

随机推荐

  1. Daily Scrum 12.2

    今日完成任务: 完成数据库文档说明:整理数据库(没整理完),明天继续:文档功能的修改以及在服务器上测试 明日任务: 黎柱金 整理数据库 孙思权 整理数据库 晏旭瑞 文档上传下载功能 冯飘飘 修复问题提 ...

  2. 1029. Median (25)

    分析: 考察归并排序,用简单的快排会超时. #include <iostream> #include <stdio.h> #include <algorithm> ...

  3. 实现毛玻璃模糊效果/DRNRealTimeBlur

    四种方法:1.美工出图  2.coreImage框架,高斯效果 3.ToolBar,覆盖在view上边 //1.添加图片 self.imageView.image = [UIImage imageNa ...

  4. 内置函数 和 select练习3

    19.  查询选修"3-105"课程的成绩高于"109"号同学成绩的所有同学的记录. select * from score where cno='3-105' ...

  5. 开始学CI

    未来一段时间的学习计划 1.codeIgniter 2.angular JS 深入 3.react 4.python 边工作边学习,保持进步

  6. C++二级指针第三种内存模型

    #include "stdio.h" #include "stdlib.h" #include "string.h" void main() ...

  7. Titanium系列--Titanium的简介、Titanium Studio安装和配置(一)

    1. 是什么?--是一个可以通过javascript,html,css等web技术开发移动App的的开发框架,媲美原生App体验和性能,目前支持IOS和Android平台. 2. 为什么能做这个? - ...

  8. delphi常用快捷键(我自己经常使用的)

    代码编辑器: Home 回到当前行的头部 End 回到当前行的尾部 Insert 插入代码,覆盖后面的代码,(按回车无效), 再按撤回效果 Delete 删除 F1 双击一个单词后,按F1调用自带的L ...

  9. sql语句对数据库表进行加锁和解锁

    锁是数据库中的一个非常重要的概念,它主要用于多用户环境下保证数据库完整性和一致性. 我们知道,多个用户能够同时操纵同一个数据库中的数据,会发生数据不一致现象.即如果没有锁定且多个用户同时访问一个数据库 ...

  10. PROTEL DXP原理图编译 常见错误与处理方法

    一, [Warning] AUDIO.SCH Extra Pin R509-1 in Normal of part R509      [Warning] AUDIO.SCH Extra Pin R5 ...