Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.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 Gmail API中的查询搜索不';不能作为web版本使用_Python_Gmail Api - Fatal编程技术网

Python Gmail API中的查询搜索不';不能作为web版本使用

Python Gmail API中的查询搜索不';不能作为web版本使用,python,gmail-api,Python,Gmail Api,我正在尝试提取带有某种星号颜色的消息(Gmail API)。 比如蓝星 def listMessagesMatchingQuery(service, user_id='me', query=''): try: response = service.users().messages().list(userId=user_id, q=query).execute()

我正在尝试提取带有某种星号颜色的消息(Gmail API)。 比如蓝星

def listMessagesMatchingQuery(service, user_id='me', query=''):
    try:
        response = service.users().messages().list(userId=user_id,
                                                   q=query).execute()
        print(response)
        messages = []
        if 'messages' in response:
            messages.extend(response['messages'])

        while 'nextPageToken' in response:
            page_token = response['nextPageToken']
            response = service.users().messages().list(userId=user_id, q=query,
                                                   pageToken=page_token).execute()
            messages.extend(response['messages'])
        return messages

    except errors.HttpError as error:
        print('An error occurred: %s' % error)


print(listMessagesMatchingQuery(GMAIL, query="has:blue-star"))

而且它不像网络版那样工作,它返回0封电子邮件。另一个查询运行良好(尝试了“from:…”、“has:attachment”、“has:drive”、“before:…”、“after:…”等)。找不到解决方案,我需要按星星的颜色对电子邮件进行排序

在Gmail API中查询超级明星相当棘手。对于蓝星,您可能需要将其更改为例如
l:^ss\u sb
,例如

has:yellow star l:^ss\u sy
has:蓝星l:^ss\u sb
has:红星l:^ss\U sr
has:橙色星l:^ss\u so
has:绿星l:^ss\U sg
has:紫星l:^ss\U sp
has:red bang l:^ss\u cr
has:yellow bang l:^ss\cy
有:蓝色信息l:^ss\U cb
哈斯:橙色吉勒迈特l:^ss_公司
has:绿色支票l:^ss\U cg
has:紫色问题l:^ss\U cp

在Gmail API中查询超级明星相当棘手。您可能需要将其更改为蓝色星星,例如。非常感谢。这有助于@Tholle
has:yellow-star <=> l:^ss_sy
has:blue-star <=> l:^ss_sb 
has:red-star <=> l:^ss_sr 
has:orange-star <=> l:^ss_so
has:green-star <=> l:^ss_sg
has:purple-star <=> l:^ss_sp
has:red-bang <=> l:^ss_cr
has:yellow-bang <=> l:^ss_cy
has:blue-info <=> l:^ss_cb
has:orange-guillemet <=> l:^ss_co
has:green-check <=> l:^ss_cg
has:purple-question <=> l:^ss_cp