只是要确保我正确地执行了文档注释

时间:2019-05-27 20:32:41

标签: python-2.7 function comments documentation pydoc

我只想确保我的文档注释正确。我正在通过LPTHW工作(第50次,哈哈,只是继续前进并重新启动),而我正在通过ex35工作。根据我的理解,#注释用于解释代码的工作方式,而文档注释似乎更多地是关于代码的用途。话虽如此,如果有人可以看看我的代码,让我知道我是否走在正确的道路上,并提供任何指针,我将非常感激。谢谢大家!

以下是我如何编写“ gold_room()”文档的示例:

    # creates a function called 'gold_room' which takes no parameters
    def gold_room(): 
    """gold_room() asks the player to input how much 
    gold they would like to take from the gold room. It checks the 
    players input to enure that its a number. If it's not, the player 
    will get a 'dead' msg and the game will use the 'dead' function to 
    end and exit the game. If it is a number, it will check if that 
    number is above or below 50. If above,the player will get a 
    'dead' msg and end and exit the game. If it is below
    50, the player will get a win msg then end and exit the game
    """

    print "This room is full of gold. How much do you take?"

    next = raw_input('>')

    if "0" in next or "1" in next: 
        how_much = int(next)

    else:
        dead("Man, learn to type a number.")

    if how_much < 50:
        print "Nice, you're not greedy, you win!"
        exit(0)
    else:
        dead("You greedy bastard!")

0 个答案:

没有答案