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.
関数内に変数を作成し、そのスクリプトをインポートして別のスクリプトでその関数を実行することにより、その関数を使用するにはどうすればよいですか?
a.py
def function_to_use(データ): use_var = データ use_var を返す
b.py
インポート function_to_use から __name__ == '__main__' の場合: print function_to_use(6)