02 2017 档案

摘要:#!/usr/bin/env python# coding=utf-8 __metaclass__ = type class StaticMethod: @staticmethod def foo(): print "This is static method foo()." class Class 阅读全文
posted @ 2017-02-07 16:49 紫色物语 阅读(154) 评论(0) 推荐(0)
摘要:编程实现:a[0]*b[0] + a[1]*b[1] +...+a[i]*b[j] >>> a=[1,2,3,4,5]>>> b=[6,7,8,9,0] >>> from functools import reduce>>> from operator import add,mul>>> reduc 阅读全文
posted @ 2017-02-05 21:48 紫色物语 阅读(168) 评论(0) 推荐(0)
摘要:>>>def foo(x,y,z,*args,**kargs): print x print y print z print args print kargs >>> foo(1,2,3,4,5,name="qiwsir",age=37) 1 2 3 (4, 5) {'name': 'qiwsir' 阅读全文
posted @ 2017-02-05 18:28 紫色物语 阅读(197) 评论(0) 推荐(0)
摘要:#!/usr/bin/env python # coding=utf-8 阅读全文
posted @ 2017-02-03 18:06 紫色物语 阅读(189) 评论(0) 推荐(0)
摘要:>>> myinfor = {"name":"qiwsir","site":"qiwsir.github.io","lang":"python"} >>> dict(zip(myinfor.values(),myinfor.keys())) { 'qiwsir': 'name', 'python': 阅读全文
posted @ 2017-02-03 17:11 紫色物语 阅读(240) 评论(0) 推荐(0)
摘要:>>> a = [1,2,3,4,5] >>> b = [9,8,7,6,5] >>> length = len(a) if len(a)<len(b) else len(b) >>> length 5 >>> c = zip(a,b) >>> c [(1, 9), (2, 8), (3, 7), 阅读全文
posted @ 2017-02-03 16:28 紫色物语 阅读(3254) 评论(0) 推荐(0)