2017-11-06 6 views
-1

私はprintstarsを修正して文書ストリングスタイルを使用し、それら。Python 2.7、docstring(doc comments)の印刷に問題があります "functionには属性がありません_doc_"というエラーが発生しました

コードはもともとこのようなものだった:改訂

Function() 
Print "Several lines of printed material" 

、関数begin:

Function() 
"""doc comment""" 

をランナーがゴールはしていると、そのようなすべての機能( "部屋")を接続していますprintコマンドの代わりにdocコメントを出力します。

ROOMS = { 
'death': death, 
'central_corridor': central_corridor, 
'laser_weapon_armory': laser_weapon_armory, 
'the_bridge': the_bridge, 
'escape_pod': escape_pod 
} 


def runner(map, start): 

    next = start 

    while True: 
     room = map[next] 
     print "\n----------------" 
     print room._doc_ 
     next = room() 

runner(ROOMS, 'central_corridor') 

しかし、私はエラーに

'function" object has no attribute '_doc_' 

を得る例の部屋に保つ:

def central_corridor(): 
"""You wanna blow thing up. 
You running toward place for to get bomb. 
Emeny approach! 

1 = shoot at enemy 
2 = avoid emenemeny 
3 = use bad pick up line on emenie 
4 = hint""" 

#print(_doc_) 

action = int(raw_input("> ")) 

if action == 1: 
    print "He shoot you first." 
    return 'death' 

elif action == 2: 
    print "No he still gots you." 
    return 'death' 

elif action == 3: 
    print "Oh yeah sexy boy." 
    print "You get past laughing enemy." 
    return 'laser_weapon_armory' 

elif action == 4: 
    print "Emeny like good joke." 
    return 'central_corridor' 

else: 
    print "You enter wrong input" 
    return 'central_corridor' 

誰がどのようにdocコメントが印刷さに到達するために教えてもらえますか?ありがとう!

答えて

0

注目のドキュメントには2つのアンダースコアが必要です。固定

_doc_ 

__doc__ 
関連する問題