Python自学:第四章 切片】的更多相关文章

# -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(players[0:3]) 输出为: ['charles', 'martina', 'michael'] 2.中间提取 # -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(players[…
# -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print("Here are the first three players on my team:") for player in players[:3]: print (player.title()) 输出为: Here are the first three players on my team: Charle…
# -*- coding: GBK -*- my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] print("My favorite foods are:") print(my_foods) print("\nMy friend's favorite foods are:") print(friend_foods) 输出为: My favorite foods are:…
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ", that was a great trick!") print("I can't wait to seee your next trick," + magician.title() + ".\n") print…
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ", that was a great trick!") print("I can't wait to seee your next trick," + magician.title() + ".\n") 输出为:…
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title() + ", that was a great trick!") 输出为: Alice, that was a great trick! David, that was a great trick! Carolina, that was a great trick…
2016/1/28学习内容 第四章 Python字符串与正则表达式之正则表达式 正则表达式是字符串处理的有力工具和技术,正则表达式使用预定义的特定模式去匹配一类具有共同特征的字符串,主要用于字符串处理,可以快速,准确地完成复杂的查找,替换等处理要求. Python中,re模块提供了正则表达式操作所需要的基本功能 正则表达式元字符 元字符: . 匹配除换行符意外的任意单个字符 元字符: * 匹配位于*之前的0个或多个字符 元字符: + 匹配位于+之前的1个或多个字符 元字符: | 匹配位于|之前或…
第四章. 控制流 控制语句后面要加冒号: 1)    if语句 if guess == number: print 'Congratulations, you guessed it.' # New block starts here elif guess < number: print 'No, it is a little higher than that' # Another block else: print 'No, it is a little lower than that' if…
Python的高级应用(一) 本章内容: 内置函数 生成器 迭代器 装饰器 JSON和PICKLE的简单用法 软件目录结构规范 一.内置函数 1.数学运算类 abs(x) 求绝对值1.参数可以是整型,也可以是复数2.若参数是复数,则返回复数的模 complex([real[, imag]]) 创建一个复数 divmod(a, b) 分别取商和余数注意:整型.浮点型都可以 float([x]) 将一个字符串或数转换为浮点数.如果无参数将返回0.0 int([x[, base]])  将一个字符转换…
ocket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. socket起源于Unix,而Unix/Linux基本哲学之一就是"一切皆文件",对于文件用[打开][读写][关闭]模式来操作.socket就是该模式的一个实现,socket即是一种特殊的文件,一些socket函数就是对其进行的操作(读/写IO.打开.关闭) socket和file的区别: file模块是针对某个…