Python 类型错误:在驱动器的特定文件夹中创建文件时,键必须是字符串

Python 类型错误:在驱动器的特定文件夹中创建文件时,键必须是字符串,python,google-app-engine,google-drive-api,Python,Google App Engine,Google Drive Api,我在GAE中使用python,我试图在一个特定的文件夹中创建一个文件。 以下是我一直在使用的代码: ... drive= build('drive', 'v2', http=http) body = { 'title': 'title', 'description': 'description', 'mimetype': 'text/plain' } body['parents'] = [{id: st

我在GAE中使用python,我试图在一个特定的文件夹中创建一个文件。 以下是我一直在使用的代码:

    ...
    drive= build('drive', 'v2', http=http)

    body = {
        'title': 'title', 
        'description': 'description',
        'mimetype': 'text/plain'
    }

    body['parents'] = [{id: str(drive_state.folderid)}]
    file = drive.files().insert(body=body).execute() 
    ...
我得到的键必须是字符串类型错误(在最后一行)。
我做错了什么?

您的身体父母必须包含一个字符串键。因此,请尝试将您的id放在引号中

body['parents'] = [{'id': str(drive_state.folderid)}]
您可以在此处找到更多信息和示例: