13

ruby ファイルの場合、次のように関数を定義します。

def tell_the_truth()
    puts "truth"
end

Pythonのメインに相当するものはありますか?

if __name__ == "__main__":
    tell_the_truth()

ファイル内の関数を呼び出すだけですか?

tell_the_truth
4

2 に答える 2

27

私はこれがうまくいくと信じています:

if __FILE__ == $0
    tell_the_truth()
end
于 2010-07-19T21:46:48.180 に答える