Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Google Drive API脚本不适用于除我自己的电子邮件之外的电子邮件_Python 3.x_Google Drive Api_Pydrive - Fatal编程技术网

Python 3.x Google Drive API脚本不适用于除我自己的电子邮件之外的电子邮件

Python 3.x Google Drive API脚本不适用于除我自己的电子邮件之外的电子邮件,python-3.x,google-drive-api,pydrive,Python 3.x,Google Drive Api,Pydrive,好的,我制作了需要一些输入的脚本,把它们放在一个字符串中,然后从我的谷歌驱动器下载user_info.txt文件,然后它将该字符串附加到该文件,并将其上传回谷歌驱动器。 它在我的机器上正常工作,但当我将exe文件与client_secrets.json一起发送给我的朋友时,他尝试了它,它说身份验证成功,但当我在谷歌硬盘上检查txt文件时,字符串没有附加到txt文件中。 因此,我的猜测是,由于某种原因,它无法在他的电脑上下载用户_info.txt文件,因为在我的代码中下载后,我没有设置删除用户_i

好的,我制作了需要一些输入的脚本,把它们放在一个字符串中,然后从我的谷歌驱动器下载user_info.txt文件,然后它将该字符串附加到该文件,并将其上传回谷歌驱动器。 它在我的机器上正常工作,但当我将exe文件与client_secrets.json一起发送给我的朋友时,他尝试了它,它说身份验证成功,但当我在谷歌硬盘上检查txt文件时,字符串没有附加到txt文件中。 因此,我的猜测是,由于某种原因,它无法在他的电脑上下载用户_info.txt文件,因为在我的代码中下载后,我没有设置删除用户_info.txt的功能,并且在他的电脑上,在运行此脚本的exe文件后,没有用户_info.txt文件。请帮忙

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from os import system, name
from time import sleep


class Register(object):
    def __init__(self):
        system('cls')
        self.fname = input("First name: ")
        system('cls')
        self.lname = input("Last name: ")
        system('cls')
        self.passw = input("Password: ")
        system('cls')


    def Upload(self):
        fileList=drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
        for files in fileList:
            if files['title'] == 'user_info.txt':
                files.GetContentFile("user_info.txt")
                update = files.GetContentString() + self.fname + " " + self.lname + " " + self.passw + "\n"
                files.SetContentString(update)
                files.Upload()   
                break   


gauth=GoogleAuth()
drive=GoogleDrive(gauth)
system('cls')


while True:
    Registration = Register()
    if Registration.fname.isalpha() == False:
        print("Invalid first name!")
        sleep(1)
        continue
    elif Registration.lname.isalpha() == False:
        print("Invalid last name!")
        sleep(1)
        continue
    else:
        Registration.Upload()
        system('cls')
        print(f"Welcome {Registration.fname} {Registration.lname}.")
        next = input("")
        system('cls')
        break
****更新****
我意识到该脚本只适用于我启用驱动API并在代码中使用的电子邮件,但对于其他电子邮件(用户),它似乎拒绝执行代码中应该下载txt文件、编辑和上载的部分。就像它拒绝连接,如果它不是我的电子邮件,但它在浏览器中说“身份验证流程已完成”。。。如何使其适用于其他电子邮件(用户)

您的朋友是否尝试直接执行
.py
文件?(不使用
.exe
)。你也有同样的行为吗?@Iamblichus他只尝试执行exe文件。好吧,也许他可以尝试这样做?@Iamblichus是的,但即使这样做有效,仍然会有exe不工作的问题(我需要exe文件),而且exe文件可以在我的电脑上运行,但不能在他的电脑上运行。你的朋友是否尝试直接执行
.py
文件?(不使用
.exe
)。你有同样的行为吗?@Iamblichus他只尝试执行exe文件。好吧,也许他可以尝试这样做?@Iamblichus是的,但即使这样做有效,仍然会出现exe不工作的问题(我需要exe文件),而且exe文件在我的电脑上工作,但在他的电脑上不工作。