zoukankan      html  css  js  c++  java
  • 初识python

    代码注释分单行和多行注释, 单行注释用#,多行注释可以用三对双引号“”” “””

    下面给大家看一段标准代码的注释,忽略代码意思

    def subclass_exception(name, parents, module, attached_to=None):
    """
    Create exception subclass. Used by ModelBase below.
    If 'attached_to' is supplied, the exception will be created in a way that
    allows it to be pickled, assuming the returned exception class will be added
    as an attribute to the 'attached_to' class.
    """
    class_dict = {'__module__': module}
    if attached_to is not None:
    def __reduce__(self):
    # Exceptions are special - they've got state that isn't
    # in self.__dict__. We assume it is all in self.args.
    return (unpickle_inner_exception, (attached_to, name), self.args)
    def __setstate__(self, args):
    self.args = args
    class_dict['__reduce__'] = __reduce__
    class_dict['__setstate__'] = __setstate__
    return type(name, parents, class_dict)

    代码注释原则:

      1. 不用给全部代码加注释,只需要在自己觉得重要或不好理解的部分加注释即可
      2. 注释可以用中文或英文,但绝对不要拼音噢
      3. 注释不光要给自己看,还要给别人看,所以请认真写
  • 相关阅读:
    ZooKeeper的工作原理
    redis 数据类型详解 以及 redis适用场景场合
    nginx负载均衡原理
    Java中缓存的介绍
    Java中接口的作用
    json与xml的区别
    最经典40个多线程问题总结
    Java线程 : 线程同步与锁
    dbcp与c3p0的区别
    Linux常见命令
  • 原文地址:https://www.cnblogs.com/jhui104/p/11443975.html
Copyright © 2011-2022 走看看