LoginSignup
0
2

More than 3 years have passed since last update.

強化学習23 Colaboratoryで自分用のmoduleを作って使う

Last updated at Posted at 2019-11-29

Colaboratoryで自分用のmoduleを作って使う方法です。

まず、GoogleDriveにmodule用のフォルダを作ります。
名前は、chokozainerRLにしました。
chokozainerRL内に、空のファイル __init__.py を作ります。
VSCodeでファイルを作って、アップロードしました。
次に、以下のようなtest.pyファイルを作ってアップロードします。

test.py
class Test:
  def sayStr(self, str):
    print(str)
chokozainer フォルダ内
    __test__.py
    test.py

notebookは以下のような感じです。

import google.colab.drive
google.colab.drive.mount('gdrive')
!ln -s gdrive/My\ Drive mydrive
!ln -s gdrive/My\ Drive/chokozainer chokozainer

from chokozainerRL import test
a=test.Test()
a.sayStr("Hello Papa")

プログラムが大きくなってくると、自分用のmoduleを作ったほうが便利になります。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2