PyCharm快速包围

问题描述

想要快速做异常处理,手写try…except太慢了,在代码很长的情况下更容易出错

def divide(a, b):
    return a / b

解决方案

  1. 选中代码块
  2. Code→Surround with
    在这里插入图片描述
  3. 选择对应模块
    在这里插入图片描述
  • if:判断,if True:
  • while:判断,while True:
  • try / except:捕捉异常
  • try / finally:捕捉异常
  • <editor-fold…> Comments:标签形式的范围注释
  • region…endregion Comments:范围注释

参考文献

  1. Getting started - Help | PyCharm
发布了223 篇原创文章 · 获赞 63 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/lly1122334/article/details/103984515
今日推荐