摘要: 注:使用函数显示地检查类型会毁掉多态,尽量避免使用。type()判断基本类型:1 >>> type(123)2 3 >>> type('str')4 5 >>> type(None)6 函数或者类:1 >>> type(abs)2 3 >>> type(a)4 types模块:1 >>> impor... 阅读全文
posted @ 2016-01-14 21:52 utopia_8 阅读(168) 评论(0) 推荐(0)
摘要: 默认参数计算xn的函数:1 def power(x, n=2):2 s = 13 while n > 0:4 n = n - 15 s = s * x6 return s设置默认参数时,有几点要注意:必选参数在前,默认参数在后;把变化大的参数放... 阅读全文
posted @ 2016-01-14 17:17 utopia_8 阅读(148) 评论(0) 推荐(0)