- 论坛徽章:
- 2
|
本帖最后由 djzhangxing 于 2016-10-27 23:08 编辑
- In [1]: import urllib
- In [2]: urllib.quote('123')
- Out[2]: '123'
- In [3]: urllib.quote('你好')
- Out[3]: '%E4%BD%A0%E5%A5%BD'
- In [4]: dic={"a":"123","b":"你好"}
- In [5]: urllib.quote(dic)
- ---------------------------------------------------------------------------
- AttributeError Traceback (most recent call last)
- <ipython-input-5-d6d0b7327553> in <module>()
- ----> 1 urllib.quote(dic)
- /usr/local/lib/python2.7/urllib.pyc in quote(s, safe)
- 1299 safe = always_safe + safe
- 1300 _safe_quoters[cachekey] = (quoter, safe)
- -> 1301 if not s.rstrip(safe):
- 1302 return s
- 1303 return ''.join(map(quoter, s))
- AttributeError: 'dict' object has no attribute 'rstrip'
复制代码 字典格式该如何转换呢?
|
|