摘要: keys = ['Name', 'Sex', 'Age']values = ['Tim', 'Male', 23] dic = dict(zip(keys, values))#{'Age': 23, 'Name': 'Tim', 'Sex': 'Male'} 阅读全文
posted @ 2015-10-28 09:21 arhatlohan 阅读(599) 评论(0) 推荐(0) 编辑
摘要: numList = [1,2,3,4,5] sum = sum(numList) #sum = 15maxNum = max(numList) #maxNum = 5minNum = min(numList) #minNum = 1from operator import mulprod =... 阅读全文
posted @ 2015-10-28 09:16 arhatlohan 阅读(20935) 评论(0) 推荐(0) 编辑
摘要: strList = ["Python", "is", "good"] res = ' '.join(strList) #Python is good res = ''for s in strList: res += s + ' '#Python is good #最后还有个多余空格 阅读全文
posted @ 2015-10-28 09:15 arhatlohan 阅读(970) 评论(0) 推荐(0) 编辑
摘要: def reverse_str( s ): return s[::-1] def reverse_str( s ): t = '' for x in xrange(len(s)-1,-1,-1): t += s[x] return t 阅读全文
posted @ 2015-10-28 09:13 arhatlohan 阅读(168) 评论(0) 推荐(0) 编辑