我正在尝试使用Requests库在 Mac(OS X 10.10)上使用 Python 3.4 对 Slack 进行 POST 调用,如下所示:
url = 'https://slack.com/api/files.upload'
with open('File β.txt', 'rb') as file:
r = requests.post(url, files={'file': file}, params={
'token': api_token,
'channels': channel
})
但后来我收到了来自 Slack 的“no_file_data”响应。如果我使用 ASCII“B”字符而不是 unicode beta,那么它可以正常工作。
我的文件是 UTF-8 编码的,我的 hashbang 下面有这一行:
# -*- coding: UTF-8 -*-
这是 Slack 的问题,还是我在 Python 中做错了什么?