Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.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 使用PyDrive访问共享文件_Python_Google Drive Api_Pydrive - Fatal编程技术网

Python 使用PyDrive访问共享文件

Python 使用PyDrive访问共享文件,python,google-drive-api,pydrive,Python,Google Drive Api,Pydrive,在我的应用程序中,使用PyDrive和Google Drive,用户a创建了一个文件,并使用 self.User.GoogleFile.SetContentString(json.dumps(self.Message)) 并且该文件与用户B共享 self.Message=json.loads(self.User.GoogleFile.GetContentString()) 消息包含正确的数据。如果用户A修改了self.Message,并使用 self.User.GoogleFile.SetC

在我的应用程序中,使用PyDrive和Google Drive,用户a创建了一个文件,并使用

self.User.GoogleFile.SetContentString(json.dumps(self.Message))
并且该文件与用户B共享

self.Message=json.loads(self.User.GoogleFile.GetContentString())
消息包含正确的数据。如果用户A修改了self.Message,并使用

self.User.GoogleFile.SetContentString(json.dumps(self.Message))
然后,如果用户B再次读取该文件,self.Message只包含原始数据,而不是更新的值


是否有任何方法可以刷新文件、清除缓存,或者我应该运行任何命令让用户B获取最新数据?

我现在意识到您需要刷新Google文件列表的实例

我是这么做的

drivefiles  = drive.ListFile().GetList()
self.User.GoogleFile = None
while True:    
    for f in drivefiles:
        if f['title'] == 'Hello.txt':
            self.User.GoogleFile = f
            break
        if self.User.GoogleFile!=None:
            self.Message=json.loads(self.User.GoogleFile.GetContentString())
    raw_input("Press Enter to continue...")
当我需要这样做的时候

while True:    
    drivefiles  = drive.ListFile().GetList()
    self.User.GoogleFile = None
    for f in drivefiles:
        if f['title'] == 'Hello.txt':
            self.User.GoogleFile = f
            break
        if self.User.GoogleFile!=None:
            self.Message=json.loads(self.User.GoogleFile.GetContentString())
    raw_input("Press Enter to continue...")