【问题标题】:importing class from icloud in python在python中从icloud导入类
【发布时间】:2020-06-09 02:02:15
【问题描述】:

我从万维网下载了一个包含类的 python 程序。我已将其存储在“iCloud/Document/Work/Code Library/program.py”中。它包含我要导入的 Class1。

我将它存储在 icloud 上,这是我无法更改的条件。

我正在创建一个 ipynb,它也在 icloud 上。如何从我下载的程序中导入库。

如何导入?谢谢。

【问题讨论】:

标签: python-import icloud


【解决方案1】:

你可以使用 PyiCloud 解决这个问题:

from pyicloud import PyiCloudService

# connect to the API
username = 'yourusername@apple.com'
password = 'password123'
api = PyiCloudService(username, password)

files = api.files.dir()

# you can figure out the file path
file_name = 'pythonfile.py'
download = api.files['com~apple~Notes']['Documents'][file_name].open(stream=True)

我假设之后你可以直接导入它,但如果你不能,你总是可以将它作为文件复制到本地设备然后导入它:

import pythonfile

之后,您可以根据需要将其删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    • 2015-05-31
    • 2020-07-23
    • 2017-08-31
    • 1970-01-01
    相关资源
    最近更新 更多