2016年12月19日

class的使用

摘要: class test(object): """ get被称之为test对象的方法 """ def __init__(self,var1): self.var1 = var1 def get(self,a=None): return self.var1 pass def get(a): return 阅读全文

posted @ 2016-12-19 15:34 chenxiaoyong 阅读(152) 评论(0) 推荐(0) 编辑

lambda 的使用汇总

摘要: 1.lambda是一个表达式。 2.它没有名称,存储的也不是代码块,而是表达式。 3.它被用作执行很小的功能,不能在里面使用条件语句。 阅读全文

posted @ 2016-12-19 15:07 chenxiaoyong 阅读(321) 评论(0) 推荐(0) 编辑

作用域

摘要: 全局变量: 阅读全文

posted @ 2016-12-19 14:45 chenxiaoyong 阅读(93) 评论(0) 推荐(0) 编辑

模块的整理汇总

摘要: import urllib 和网页相关模块 import glob import os import sys import time import math 数学模块 模块的导入方式 import module from module import math from module import a 阅读全文

posted @ 2016-12-19 12:54 chenxiaoyong 阅读(137) 评论(0) 推荐(0) 编辑

函数使用的健壮性

摘要: 1.永远知道使用的方法会返回什么,增加判断或者异常监控 2.返回你想要的结果 阅读全文

posted @ 2016-12-19 10:20 chenxiaoyong 阅读(412) 评论(0) 推荐(0) 编辑

内置默认方法汇总

摘要: isinstance() 函数带两个参数第一个传入参数,第二个是传入的参数类型判断如: def add(num1=10,num2=15): if isinstance(num1,int) and isinstance(num2,int): return (num1+num2) else: retur 阅读全文

posted @ 2016-12-19 10:13 chenxiaoyong 阅读(165) 评论(0) 推荐(0) 编辑

函数的使用

摘要: #* 将传入参数编程元组,满足不同参数输入def add(*num): d=0 for i in num: d+=i return dprint(add(1,2,3,4,5,6,7)) 阅读全文

posted @ 2016-12-19 10:01 chenxiaoyong 阅读(112) 评论(0) 推荐(0) 编辑

导航