摘要: 一、切片L = [''Michael','Sarah','Tracy','Bob','Jack']取前N个元素,也就是索引为0-(N-1)的元素,可以用循环:>>> r = []>>> n = 3>>> for i in range(n): r.append(L[i])>>>r['Mich... 阅读全文
posted @ 2015-10-29 14:35 菜鸟的Blog 阅读(148) 评论(0) 推荐(0) 编辑
摘要: python中有很多字符串连接方式,总结一下:1 最原始的字符串连接方式:str1 + str22 python 新字符串连接语法:str1, str23 奇怪的字符串方式:str1 str24 % 连接字符串:‘name:%s; sex: ’ % ('tom', 'male')5 字符串列表连接:... 阅读全文
posted @ 2015-10-29 10:38 菜鸟的Blog 阅读(542) 评论(0) 推荐(0) 编辑