You are viewing a single comment's thread from:
RE: [DA series - Learn Python with Steem #03] 邏輯判斷
8 years ago in #da-learnpythonwithsteem by kona (66)
$0.13
- Past Payouts $0.13
- - Author $0.10
- - Curators $0.03
New to Steemistry?
Promoted Posts
- Fifteen new cards added to the animalCards deck - All categories are full, except for the reptiles & amphibians [burnsteem100]@remlaps-lite
- Juvenile Bald Eagles at the Conowingo Dam on October 17, 2026@remlaps
- Reblog: OSIRIS-REx probe lands on asteroid Bennu and collects a small sample@remlaps-lite
有個問題,為什麼我在line6, 如果不打東西會顯示IndentationError,可是這樣加上print(''),好像有點多餘,求解答!
应该是不写东西不符合Python的语法。
在 if True: 的后面要写做出选择后要做的事情,什么都不做写个pass,像这样:
如果加了pass为什么再加其他的语句还是会被运行?pass的作用是?
你是说这样的情况吗?pass不是跳过某段程序的意思
pass 是用来占位子的,为了让写的程序符合语法,就像上面那样
我知道的pass有两个作用:
一是像上面那样,什么都不做;
另一个是,还没想好程序的某个功能怎么写,写个pass占位子,以后有思路了再完善程序。
哦,理解了,我以为是整个if内的都pass,看来是我理解错了!多谢!
你可以吧这个print换成pass

这样符合语法,但是你这个if里就不要写其他的了,因为我不知道pass是什么作用,只是加了后语法正常能够过编译,如果你加了其他东西,那所加的内容还是会正常运行的。
對,聽高手@yjcps的!
高手都不露面的
你是幕后高手:)
謝謝各高手,學了pass,
還想問問,沒看清題目,這樣用上elif好還是只用if..else好?
语句是死的用法是活得,一般没用到的我都保持知道有这个知识点,需要的时候再用,平时都是怎么好用怎么来!PS我也没用elif,你想都用的话写两段也可以呀,嘻嘻!可以多读读互相的代码!
Posted using Partiko Android
謝謝