发布于 2017-05-22 03:04:17 | 172 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Python多线程编程,程序狗速度看过来!

Python编程语言

Python 是一种面向对象、解释型计算机程序设计语言,由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年。Python语法简洁而清晰,具有丰富和强大的类库。它常被昵称为胶水语言,它能够把用其他语言制作的各种模块(尤其是C/C++)很轻松地联结在一起。


这篇文章主要介绍了Python 字符串(string) 的相关资料,需要的朋友可以参考下

Python字符串(string) 详解 及 代码

Python的字符串可以使用单引号('), 双引号("), 三引号('''); 三引号(''')里面, 可以添加单引号和双引号, 也可以通过转义序列(\)添加;
字符串放在一起自动连接成为一个字符串;

字符串前面添加限定词R或r, 表示是自然字符串(nature string), 可以忽略里面的格式限制;

在物理行末尾添加"\", 可以连接下一个物理行; 括号, 方括号, 大括号也可以一定限度的扩充物理行;

具体参见代码注释;

代码如下:


# -*- coding: utf-8 -*- 
 
#==================== 
#File: abop.py 
#Author: Wendy 
#Date: 2013-12-03 
#==================== 
 
#eclipse pydev, python3.3 
 
#三引号可以自由的使用双引号("")和单引号('') 
s = ''''' I am a girl and like heels. 
Hello, "python" sister. ''' 
 
#转义序列"\" 
st = '''''Hello, girls, l like (\'''). ''' 
 
#字符串放在一起自动连接 
sa = 'Girls are ''the best. ' 
 
#r表示自然字符串, 不会进行转义(\n) 
sr = r"nature is good. \n {0}" 
 
#"\"表示连接字符串 
sc = 'Oh, the lines are too \ 
large' 
 
#括号, 方括号, 大括号, 可以限定范围, 不用使用转义 
print("the braces can do {thing}.". 
   format(thing="lady")) 
 
print(s) 
print(st) 
print(sa) 
print(sr) 
print(sc) 

输出:


the braces can do lady. 
 I am a girl and like heels. 
Hello, "python" sister.  
Hello, girls, l like (''').  
Girls are the best.  
nature is good. \n {0} 
Oh, the lines are too large 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务