python pass

在system-config-services源码包中常看到pass,而且常在
那么pass到底是什么?

一、实例

def on_systemd_manager_discovery_started(self, manager):
      pass

def run(self):
      try:
            self.mainWindow.toplevel.show()
            self.mainloop.run()
      except KeyboardInterrupt:
            pass

二、实例详解

pass在Python中作为空语句,这是为了保持程序的完整性。一般在空函数或者异常中使用。
它不做任何事,只是代表占位语句。在Python2上必须添加,而在
Python3上可写可不写。

作者:yusq77

-------------------------------------------

Wish you all the best and good health in 2021.

原文地址:https://www.cnblogs.com/yusq77/p/13573516.html