如何在 google collab 中 python 文件中的 运行 方法?

How to run method inside python file in google collab?

我目前正在从 github 克隆一个 .py 文件,我想在其中使用一个方法。

克隆成功,但我无法访问其中的文件和方法。我试过 import fileName 但它不起作用。

git clone 将创建一个与 Gist 同名的文件夹,在本例中为 3b6a91cefb2f5c3098ed。您可以将其添加到如下路径中。 (但是,模块中似乎存在错误 - 或者我不了解与模块相关的内容)。

!git clone https://gist.github.com/3b6a91cefb2f5c3098ed.git
import sys 
sys.path.append("3b6a91cefb2f5c3098ed")
import playmidi