10
2022
03

Import ipynb files from google Drive to Colab

import function or class from anohter ipynb files to this notebook.

Why not put the function or class directly to this notebook?

It is because the code of function or class may be so long or common usage to communicate between other ipynb files. 

To handle it easily, the function or class may place into another ipynb for storage.


import os
from google.colab import drive
drive.mount('/content/drive', force_remount=False)

os.chdir("/content/drive/MyDrive/Colab_Notebooks")

try:
  import import_ipynb
except:
  !pip install import-ipynb
  import import_ipynb

import Your_File_Name
from Your_File_Name import Your_Class_Name #or function name


#execute your code


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。