Python
Mister_Wisdom
热爱生活,迷恋编程。
展开
-
不要把 Python 写成 C 语言版的 Python
如果你像我一样,大学第一门编程语言是以 C 语言开始的,再学 Python 的时候可能还是忘不掉 C 语言的那种编程思维。 举例: 1、数值计算类(举一个小学生都会算的题):从1到100中取出所有偶数,把取出的偶数各自乘以2,再把所得的这些结果相加求和: (1) 如果是 C 语言,就可以这么干: int result = 0; int i; for (i=1; i<101; ++i原创 2015-08-29 01:29:12 · 2003 阅读 · 0 评论 -
Python 类的魔力特性之一:property
如果你有一个 Person 类(其中3个属性:first_name、second_name、full_name): class Person(object): def __init__(self, first_name, second_name): self.first_name = first_name self.second_name = second_name self.fu原创 2015-10-28 14:38:07 · 509 阅读 · 0 评论