为什么在调用.LocalWebserverAuth之后无法打印使用PyDrive 2的python代码? python新手

问题描述

我试图理解为什么我的代码会创建新的txt文件,但不会打印“ Authenticated”或“ Done”。似乎“ gauth.LocalWebserverAuth()”之后的任何代码都不会输出。 python btw的新手。

from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive

print("Authenticating")

gauth = GoogleAuth()
print("1")
gauth.LocalWebserverAuth()# client_secrets.json need to be in the same directory as the script
drive = GoogleDrive(gauth)

print("Authenticated")

file1 = drive.CreateFile({'title': 'Hello.txt'})  # Create GoogleDriveFile instance with title 'Hello.txt'.
file1.SetContentString('Hello World!') # Set content of the file from given string.
file1.Upload()
print("Done")''

输出

认证

1

您的浏览器已打开以访问:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2fdrive&access_type=offline&response_type=code&client_id="myclientid...etc"

为什么不打印“ Authenticated”或“ Done”?谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)