시도해 봤는데 내 경우에도 작동하지 않습니다.
.encode()를 중국어 사용자 이름에 적용하거나 urllib.parse.quote()를 사용해도
headers = {
'Api-Key': API_KEY,
'Api-Username': '大帅哥'.encode()
}
# 또는 urllib parse
headers = {
'Api-Key': API_KEY,
'Api-Username': urllib.parse.quote(API_USERNAME)
}
에러가 발생합니다.
Failed to create post. Status code: 403
{'errors': ['您没有权限查看请求的资源。API 用户名或者密钥无效。'], 'error_type': 'invalid_access'}
하지만 .encode()를 사용하지 않으면
headers = {
'Api-Key': API_KEY,
'Api-Username': '大帅哥'
}
에러가 발생합니다.
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)