[英]TypeError: got an unexpected keyword argument “name”
The seemingly simple code below throws the following error 下面看似简单的代码将引发以下错误
Traceback (most recent call last): File "search.py", line 48, in pageToken=page_token).execute() File "C:\\Users\\Choi\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\googleapiclient\\discovery.py", line 716, in method
追溯(最近一次通话最后一次):文件“ search.py”,第48行,在pageToken = page_token中).execute()文件“ C:\\ Users \\ Choi \\ AppData \\ Local \\ Programs \\ Python \\ Python37 \\ lib \\ site- package \\ googleapiclient \\ discovery.py”,方法中的第716行
raise TypeError('Got an unexpected keyword argument "%s"' % name) TypeError: Got an unexpected keyword argument "name"
引发TypeError('获得了意外的关键字参数“%s”'%名称)TypeError:得到了意外的关键字参数“ name”
Code: 码:
scope = 'https://www.googleapis.com/auth/drive'
credentials = ServiceAccountCredentials.from_json_keyfile_name('pyGD-eadb4d7ba057.json', scope)
http = credentials.authorize(httplib2.Http())
drive_service = discovery.build('drive', 'v3', http=http)
page_token = None
print('While START::::')
while True:
response = drive_service.files().list(name = 'hello',
spaces='drive',
fields='nextPageToken, files(id, name)',
pageToken=page_token).execute()
for file in response.get('files', []):
#Process change
print('RESULT::::')
print ('Found file: %s (%s)' % (file.get('name'), file.get('id')))
page_token = response.get('nextPageToken',None)
if page_token is None:
break
What am I doing wrong please? 请问我做错了什么? Thank you.
谢谢。
You need to use the trackback. 您需要使用引用。 Let's have a look at googleapiclient/discovery.py
让我们看看googleapiclient / discovery.py
def method(self, **kwargs):
# Don't bother with doc string, it will be over-written by createMethod.
for name in six.iterkeys(kwargs):
if name not in parameters.argmap:
>> raise TypeError('Got an unexpected keyword argument "%s"' % name)
The error was raised here. 错误在这里提出。 You have a wrong argument called
name
. 您有一个错误的论点,叫做
name
。
According to the documentation , the query should be in argument q
. 根据文档 ,查询应在参数
q
。
response = drive_service.files().list(q="name='hello'",
spaces='drive',
fields='nextPageToken, files(id, name)',
pageToken=page_token).execute()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.