Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
pydev で「Main」という名前のファイルを作成し、その中に次のように書きました。
if __name__ =='__Main__': main() def main(): print("jargon")
if ステートメントの下の main() への呼び出しに未定義の変数が含まれているため、コンパイルされません。なぜこれを行うのですか?
Python コードは上から下に実行されます。main()定義をif __name__ == '__main__'ブロックの上に移動する必要があります。あなたがそれを持っている方法、あなたが呼び出そうとした時点ではmain()、関数はまだ存在していません。
main()
if __name__ == '__main__'