Python异常和错误处理时,try...except、if...else...哪个更好一些,为什么?Thepointisthatusingtry/exceptstatementsisinmanycasesmuchmorenatural(more“Pythonic”)thanif/else,andyoushouldgetintothehabitofusingthemwhereyoucan.这个是《BeginningPythonFromNovicetoProfessional,2ndEdition》里的原话,但StackOverflow里又有Whyis“except:pass”abadprogrammingpractice?我就疑惑了……到底哪个好一些?还是说有更好的方法?
桃花长相依
相关分类