小编And*_*rés的帖子

递归函数在Python中返回none

我有这段代码,出于某种原因,当我尝试返回路径时,我得到的是:

def get_path(dictionary, rqfile, prefix=[]):

for filename in dictionary.keys():
    path = prefix+[filename]
    if not isinstance(dictionary[filename], dict):

        if rqfile in str(os.path.join(*path)):
            return str(os.path.join(*path))

    else:
        get_path(directory[filename], rqfile, path)
Run Code Online (Sandbox Code Playgroud)

有办法解决这个问题吗?提前致谢.

python recursion

7
推荐指数
1
解决办法
1万
查看次数

Google Drive API 仅列出每个文件夹最多 100 个文件

我正在创建一个应用程序来使用 Python 备份存储在 Google Drive 中的文件。我遇到的第一个问题是,由于某种原因,它只列出每个文件夹中最多 100 个文件。我认为我使用了正确的范围(' https://www.googleapis.com/auth/drive '),这是我用来列出文件夹内容的代码行

folder_contents = service.files().list( q="'%s' in parents" % folder['id'] ).execute()
Run Code Online (Sandbox Code Playgroud)

有什么办法可以改变列出的文件的数量吗?我在此线程中发现Google Drive List API - 未列出所有文档?有一种方法可以做到这一点,但NumberToRetrieve行不通。我尝试在 Drive API 参考网页( https://developers.google.com/drive/v2/reference/files/list )中测试它,但它给了我一个错误。当我从代码中请求列表时,我也不知道如何放置此参数(我是使用 Drive API 的新手)。

提前致谢。

编辑:我找到了一种使用该标志增加文件数量的方法MaxResuls。但它只允许列出最多 1000 个,这还不够。

python google-drive-api

1
推荐指数
1
解决办法
3016
查看次数

标签 统计

python ×2

google-drive-api ×1

recursion ×1