create account

RE: [DA series - Learn Python with Steem #03] 邏輯判斷 by kona

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @kona/re-deanliu-da-series-learn-python-with-steem-03-20180730t040055295z

· @kona ·
有個問題,為什麼我在line6, 如果不打東西會顯示IndentationError,可是這樣加上print(''),好像有點多餘,求解答!
properties (22)
authorkona
permlinkre-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t040612914z
categoryda-learnpythonwithsteem
json_metadata{"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"}
created2018-07-30 04:06:15
last_update2018-07-30 04:06:15
depth2
children10
last_payout2018-08-06 04:06:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length70
author_reputation39,758,138,507,499
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,463,946
net_rshares0
@antonsteemit ·
對,聽高手@yjcps的!
properties (22)
authorantonsteemit
permlinkre-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t044337044z
categoryda-learnpythonwithsteem
json_metadata{"community":"busy","app":"busy/2.5.3","format":"markdown","tags":["da-learnpythonwithsteem"],"users":["yjcps"],"links":["/@yjcps"],"image":[]}
created2018-07-30 04:43:36
last_update2018-07-30 04:43:36
depth3
children1
last_payout2018-08-06 04:43:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation7,534,465,964,895
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,466,873
net_rshares0
@yjcps ·
高手都不露面的
你是幕后高手:)
properties (22)
authoryjcps
permlinkre-antonsteemit-re-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t052343847z
categoryda-learnpythonwithsteem
json_metadata{"community":"busy","app":"busy/2.5.3","format":"markdown","tags":["da-learnpythonwithsteem"],"users":[],"links":[],"image":[]}
created2018-07-30 05:23:42
last_update2018-07-30 05:23:42
depth4
children0
last_payout2018-08-06 05:23:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length17
author_reputation1,019,613,572,923
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,470,101
net_rshares0
@kona · (edited)
謝謝各高手,學了pass,
還想問問,沒看清題目,這樣用上elif好還是只用if..else好?
properties (22)
authorkona
permlinkre-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t052757212z
categoryda-learnpythonwithsteem
json_metadata{"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"}
created2018-07-30 05:27:57
last_update2018-07-30 05:28:48
depth3
children2
last_payout2018-08-06 05:27:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length48
author_reputation39,758,138,507,499
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,470,466
net_rshares0
@shine.wong ·
语句是死的用法是活得,一般没用到的我都保持知道有这个知识点,需要的时候再用,平时都是怎么好用怎么来!PS我也没用elif,你想都用的话写两段也可以呀,嘻嘻!可以多读读互相的代码!

Posted using [Partiko Android](https://play.google.com/store/apps/details?id=io.partiko.android)
properties (22)
authorshine.wong
permlinkshine-wong-re-kona-re-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t104523992z
categoryda-learnpythonwithsteem
json_metadata{"app":"partiko"}
created2018-07-30 10:45:24
last_update2018-07-30 10:45:24
depth4
children1
last_payout2018-08-06 10:45:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length187
author_reputation1,329,335,530,903
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,498,085
net_rshares0
@kona ·
謝謝
👍  
properties (23)
authorkona
permlinkre-shinewong-shine-wong-re-kona-re-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t104803993z
categoryda-learnpythonwithsteem
json_metadata{"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"}
created2018-07-30 10:48:06
last_update2018-07-30 10:48:06
depth5
children0
last_payout2018-08-06 10:48:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2
author_reputation39,758,138,507,499
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,498,312
net_rshares167,415,753
author_curate_reward""
vote details (1)
@shine.wong ·
$0.04
你可以吧这个print换成pass
![](https://cdn.steemitimages.com/DQmQNGcPgkeWosdePieCnKYLTwVxUjraNeUKuPt3ebiAR1d/image.png)
这样符合语法,但是你这个if里就不要写其他的了,因为我不知道pass是什么作用,只是加了后语法正常能够过编译,如果你加了其他东西,那所加的内容还是会正常运行的。
👍  
properties (23)
authorshine.wong
permlinkre-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t044907871z
categoryda-learnpythonwithsteem
json_metadata{"tags":["da-learnpythonwithsteem"],"image":["https://cdn.steemitimages.com/DQmQNGcPgkeWosdePieCnKYLTwVxUjraNeUKuPt3ebiAR1d/image.png"],"app":"steemit/0.1"}
created2018-07-30 04:49:09
last_update2018-07-30 04:49:09
depth3
children0
last_payout2018-08-06 04:49:09
cashout_time1969-12-31 23:59:59
total_payout_value0.032 HBD
curator_payout_value0.010 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length191
author_reputation1,329,335,530,903
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,467,257
net_rshares25,042,838,164
author_curate_reward""
vote details (1)
@yjcps ·
$0.04
应该是不写东西不符合Python的语法。
在 if True: 的后面要写做出选择后要做的事情,什么都不做写个pass,像这样:

``` python
if True:
    pass
```
👍  ,
properties (23)
authoryjcps
permlinkre-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t044144827z
categoryda-learnpythonwithsteem
json_metadata{"community":"busy","app":"busy/2.5.3","format":"markdown","tags":["da-learnpythonwithsteem"],"users":[],"links":[],"image":[]}
created2018-07-30 04:41:45
last_update2018-07-30 04:41:45
depth3
children3
last_payout2018-08-06 04:41:45
cashout_time1969-12-31 23:59:59
total_payout_value0.033 HBD
curator_payout_value0.009 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length98
author_reputation1,019,613,572,923
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,466,727
net_rshares25,198,253,471
author_curate_reward""
vote details (2)
@shine.wong ·
如果加了pass为什么再加其他的语句还是会被运行?pass的作用是?
properties (22)
authorshine.wong
permlinkre-yjcps-re-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t044954337z
categoryda-learnpythonwithsteem
json_metadata{"tags":["da-learnpythonwithsteem"],"app":"steemit/0.1"}
created2018-07-30 04:49:54
last_update2018-07-30 04:49:54
depth4
children2
last_payout2018-08-06 04:49:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length34
author_reputation1,329,335,530,903
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,467,316
net_rshares0
@yjcps ·
![图片.png](https://ipfs.busy.org/ipfs/QmNYpBZS6e7hqFyZsEQcys1EbXtynDdw9AXJhgEpJAAeCr)

你是说这样的情况吗?pass不是跳过某段程序的意思
pass 是用来占位子的,为了让写的程序符合语法,就像上面那样

我知道的pass有两个作用:
一是像上面那样,什么都不做;
另一个是,还没想好程序的某个功能怎么写,写个pass占位子,以后有思路了再完善程序。
properties (22)
authoryjcps
permlinkre-shinewong-re-yjcps-re-kona-re-kona-re-deanliu-da-series-learn-python-with-steem-03-20180730t052211004z
categoryda-learnpythonwithsteem
json_metadata{"community":"busy","app":"busy/2.5.3","format":"markdown","tags":["da-learnpythonwithsteem"],"users":[],"links":[],"image":["https://ipfs.busy.org/ipfs/QmNYpBZS6e7hqFyZsEQcys1EbXtynDdw9AXJhgEpJAAeCr"]}
created2018-07-30 05:22:12
last_update2018-07-30 05:22:12
depth5
children1
last_payout2018-08-06 05:22:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length218
author_reputation1,019,613,572,923
root_title"[DA series - Learn Python with Steem #03] 邏輯判斷"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,469,964
net_rshares0