在Python中,如何使用PyDrive监控文件上载进度?

2024-05-28 18:46:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我能够上传文件到谷歌驱动器使用PyDrive库。但是我想看看上传的进度(例如百分比)。我怎样才能做到这一点。以下是我的上传代码:

def uploadToGoogleDrive(myFile):
    gauth = GoogleAuth()
    gauth.LoadCredentialsFile("umocreds.txt")
    if gauth.credentials is None:
        gauth.LocalWebserverAuth()
    elif gauth.access_token_expired:
        gauth.Refresh()
    else:
        gauth.Authorize()
    gauth.SaveCredentialsFile("umocreds.txt")
    drive = GoogleDrive(gauth)
    
    driveFile = drive.CreateFile()
    driveFile.SetContentFile(myFile)
    driveFile.Upload()

Tags: 文件代码txtdefdrivemyfile百分比驱动器

热门问题