小编Wur*_*rer的帖子

使用python请求上传文件

我一直在尝试使用带有请求的方框v2 api上传文件.

到目前为止我运气不好.也许这里有人可以帮助我看看我实际上做错了什么.

file_name = "%s%s" % (slugify(sync_file.description), file_suffix)
file_handle = open(settings.MEDIA_ROOT + str(sync_file.document), 'rb')
folder_id = str(sync_file.patient.box_patient_folder_id)

r = requests.post(
    files_url,
    headers=headers,
    files={
        file_name: file_handle,
        "folder_id": folder_id,
    },
)
Run Code Online (Sandbox Code Playgroud)

我的身份验证有效,因为我正在使用相同的数据创建一个文件夹.

响应看起来像这样:

{
    u'status': 404, 
    u'code': u'not_found', 
    u'help_url': u'http://developers.box.com/docs/#errors', 
    u'request_id': u'77019510950608f791a0c1', 
    u'message': u'Not Found', 
    u'type': u'error'
}
Run Code Online (Sandbox Code Playgroud)

也许这里的某个人遇到了类似的问题.

python-requests box-api

6
推荐指数
2
解决办法
7712
查看次数

将一种查询格式传递给另一种查询格式

我很茫然.我一直试图让这个工作好几天了.但我没有得到这个,所以我想我会在这里咨询你们,看看有人能帮助我!

我正在使用pyparsing试图将一种查询格式解析为另一种查询格式.这不是一个简单的转变,但实际上需要一些大脑:)

当前查询如下:

("breast neoplasms"[MeSH Terms] OR breast cancer[Acknowledgments] 
OR breast cancer[Figure/Table Caption] OR breast cancer[Section Title] 
OR breast cancer[Body - All Words] OR breast cancer[Title] 
OR breast cancer[Abstract] OR breast cancer[Journal]) 
AND (prevention[Acknowledgments] OR prevention[Figure/Table Caption] 
OR prevention[Section Title] OR prevention[Body - All Words] 
OR prevention[Title] OR prevention[Abstract])
Run Code Online (Sandbox Code Playgroud)

使用pyparsing我已经能够得到以下结构:

[[[['"', 'breast', 'neoplasms', '"'], ['MeSH', 'Terms']], 'or',
[['breast', 'cancer'], ['Acknowledgments']], 'or', [['breast', 'cancer'],
['Figure/Table', 'Caption']], 'or', [['breast', 'cancer'], ['Section', 
'Title']], 'or', [['breast', 'cancer'], ['Body', '-', 'All', 'Words']], 
'or', [['breast', 'cancer'], …
Run Code Online (Sandbox Code Playgroud)

python lucene pyparsing pubmed

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

标签 统计

box-api ×1

lucene ×1

pubmed ×1

pyparsing ×1

python ×1

python-requests ×1