python中的Docstring 发表于 2018-06-27 | 更新于: 2018-08-02 | 分类于 Python | | 热度: 字数统计: 204 | 阅读时长 ≈ 1 基本教程1234567891011121314151617181920212223242526'''文档字符串的应用该文档字符串所约定的是一串多行字符串,其中第一行以某一大写字母开始,以句号结束。第二行为空行,后跟的第三行开始是任何详细的解释说明。 在此强烈建议你在有关你所有非凡功能的文档字符串中都遵循这一约定。'''def print_max(x, y): '''Prints the maximum of two numbers.打印两个数值中的最大数。 The two values must be integers.这两个数都应该是整数 ''' # 如果可能,将其转换至整数类型 x = int(x) y = int(y) if x > y: print(x, 'is maximum') else: print(y, 'is maximum')print_max(3, 5)print(print_max.__doc__) 打赏了解一下? 打赏 支付宝