Python:什么是标头? [英] Python: What is a header?
问题描述
我是Python和程序设计的新手.我正在上大学的一个模块,要求我用Python编写一些相当基本的程序.但是,我在上次作业中得到了以下反馈:
I'm new to Python and programming in general. I am taking a module at university which requires me to write some fairly basic programs in Python. However, I got this feedback on my last assignment:
应该有一个标题栏,其中包含文件名,作者名,创建日期,修改日期和python版本
There should be a header block containing the file name, author name, date created, date modified and python version
什么是标题块?它只是代码顶部的注释,还是在程序运行时打印的内容?还是其他?
What is a header block? Is it just comments at the top of your code or is it be something which prints when the program runs? Or something else?
推荐答案
有些东西叫做 python中的文档字符串(以下是有关如何编写python代码的一些常规约定-逃脱了,非常适合多行注释
There's thing called Docstring in python (and here're some conventions on how to write python code in general - PEP 8) escaped by either triple single quote '''
or triple double quote """
well suited for multiline comments:
'''
File name: test.py
Author: Peter Test
Date created: 4/20/2013
Date last modified: 4/25/2013
Python Version: 2.7
'''
稍后(在对模块进行编程时),您也可能会使用专用于包含以下信息的特殊变量:
You also may used special variables later (when programming a module) that are dedicated to contain info as:
__author__ = "Rob Knight, Gavin Huttley, and Peter Maxwell"
__copyright__ = "Copyright 2007, The Cogent Project"
__credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley",
"Matthew Wakefield"]
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Rob Knight"
__email__ = "rob@spot.colorado.edu"
__status__ = "Production"
在在此处答复的更多详细信息.
这篇关于Python:什么是标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!