Skip to content

Commit

Permalink
如何捅破python编程的那层纸
Browse files Browse the repository at this point in the history
  • Loading branch information
likepython committed Oct 14, 2015
1 parent b769c29 commit a05fdf5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pythonstudy.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
编程思路的养成需要一个过程的,在编码过程中思考,多动手敲代码。
有时候,想不明白的地方,有人稍微点破一下,那层纸就很容易破。
请看下面的例子。


#编程思路一:
经常有人问,一个文本文件,要抽取多少行以后的文本。
相信记数循环,大家都看得懂,也会写。下面的代码就是利用记数循环来解决这个问题。
相信计数循环,大家都看得懂,也会写。下面的代码就是利用记数循环来解决这个问题。

代码一:
一个几M的文本文件,需要每隔100行写到新的文件中。
Expand All @@ -18,7 +18,7 @@
# coding:utf-8
"""
迪艾姆python远程视频培训

咨询:qq:1465376564

"""
Expand Down Expand Up @@ -53,24 +53,24 @@
#coding:utf-8
"""
本代码由迪艾姆公司黄老师所写,思路大家自己看代码。

抓了a,b,c,d4名犯罪嫌疑人.其中有一名是小偷,审讯中:
a说我不是小偷
b说c是小偷
c说小偷肯定是d
d说c胡说!
其中有3个人说的是实话,一个人说的是假话,编程推断谁是小偷。
(用穷举法和逻辑表达式)

"""

for thief in ['a','b','c','d']:

sum = (thief != 'a') + (thief == 'c') + (thief == 'd') + (thief !='d')
if sum == 3:
print "小偷是:%s " % thief



总结:
学习python编程,先学会过程式编程,再过度到面向对象的编程范式。
Expand All @@ -83,8 +83,8 @@

[迪艾姆python培训_python编程思路二 ]
(http://v.youku.com/v_show/id_XNTY0MDE1NzA0.html)
[python爬虫之采集搜素引擎联想词 ]

[python爬虫之采集搜素引擎联想词 ]
(http://www.tudou.com/programs/view/SXgshk-sYbw/)

[广告:如果自学有困难,建议参加迪艾姆python培训,可以节省学习成本。](https://github.com/pythonpeixun/article/blob/master/index.md)
[广告:如果自学有困难,建议参加迪艾姆python培训,可以节省学习成本。](https://github.com/pythonpeixun/article/blob/master/index.md)

0 comments on commit a05fdf5

Please sign in to comment.