• 2024-08-24try的简单性能测试
    #1.测试对函数类型检查使用捕捉异常和if先判断方式的时间差fromtimeitimporttimeitdefincrement_lbyl(x):ifisinstance(x,int):returnx+1elifisinstance(x,str)andx.isdigit():returnint(x)+1else:pass#
  • 2024-07-31Python - Strategies to handle exceptions in your code
    Therearetwoapproachesthatcanbefollowedwhenwewanttodealwithexceptionsthatoccurduetounusualevents:LBYL-LookBeforeYouLeapEAFP-EasiertoAskforForgivenessthanPermissionIntheLBYLapproach,weavoidexceptions,whileinthe