unicode中的Python请求

unicode中的Python请求,python,unicode,steam-web-api,Python,Unicode,Steam Web Api,我正试图做一个程序,要求蒸汽得到一个最便宜的价格为一个项目。为此,我将使用StatTrak™ P250 |超新星(新工厂)为例 问题是,在请求时,您将创建一个url: http://www.steamcommunity.com/market/priceoverview/?country=SG&currency=13&appid=730&market_hash_name=StatTrak™%20P250%20%7C%20Supernova%20%28Factory%20Ne

我正试图做一个程序,要求蒸汽得到一个最便宜的价格为一个项目。为此,我将使用StatTrak™ P250 |超新星(新工厂)为例

问题是,在请求时,您将创建一个url:

http://www.steamcommunity.com/market/priceoverview/?country=SG&currency=13&appid=730&market_hash_name=StatTrak™%20P250%20%7C%20Supernova%20%28Factory%20New%29
之后,(我正在使用请求模块)我会执行以下操作:

url = "http://www.steamcommunity.com/market/priceoverview/?country=SG&currency=13&appid=730&market_hash_name=StatTrak™%20P250%20%7C%20Supernova%20%28Factory%20New%29"
requests.get(url)
但是,服务器将返回一个错误


我似乎找不到替代的办法™. 我试过
%2122
。在python中,我尝试使用
u'\u084a'
,但效果不太好。问题是python在请求中发送字面上的
\u084a
。有什么办法可以解决这个问题吗?

只需使用URL编码。您不能在URL中使用unicode

>>> import urllib 
>>> f = {'market_hash_name': 'StatTrak™'}
>>> urllib.urlencode(f)
'market_hash_name=StatTrak%E2%84%A2'
也可能

>>> urllib.quote_plus('StatTrak™')

您需要正确地编码和引用参数;请看副本。