在 windows 桌面上试用 PyDrive

try out PyDrive in windows desktop

我正在关注 this 以学习如何使用 PyDrive 库

我在 ....PycharmProjects\Qt\venv\Lib\site-packages 安装了 PyDrive 我复制代码并保存在 c:\users\me\test.py

现在我不知道如何 运行 它。我的 google 驱动器帐户已经存储了一些文件。

我需要简单的步骤 运行 从命令提示符或空闲或 PyCharm 我需要 Google 云帐户或其他任何东西吗?

我改为(venv)c:\user\me\test.py

我明白了

ERROR  File "..\PycharmProjects\Qt\venv\lib\site-packages\oauth2client\clientsecrets.py", line 121, in _loadfile
    with open(filename, 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'client_secrets.json'
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)

file1 = drive.CreateFile({'title': 'Hello.txt'})
file1.SetContentString('Hello')
file1.Upload() 


docsfile.GetContentFile('test.html', mimetype='text/html')

PyDrive 已弃用,取而代之的是 PyDrive2 (pip install PyDrive2)

所有 Google SDK 都需要身份验证令牌,您可以 refer to the documentation on how to generate one 以及在何处创建由库读取的 JSON 文件(在您的工作目录中)

另请务必阅读 official Google Drive Python API page