For compatibility, you can only select a compatible: colon.
It's easy to change the Cookie.morsel
Copy Code code as follows:
#!/usr/bin/python
#-*-Coding:utf-8-*-
"" "Morselhook, fix Cookie.CookieError:Illegal key value:ys-tab:entrance:e
"""
Import Cookie
Import string
_morsel = Cookie.morsel
Class Morselhook (_morsel):
"""
>>> Import Inspect
>>> (Inspect.getargspec (Morselhook.set) [3]) [0]
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789!#$%& ' *+-.^_ ' |~:"
>>> cookies = Cookie.simplecookie ()
>>> cookie.load ("YS-TAB:ENTRANCE:E=ABC; Webpy_session_id=75eb60dcc83e2d902146af0bb7f47afe61fbd2b2 ")
>>> Print Cookies
SET-COOKIE:WEBPY_SESSION_ID=75EB60DCC83E2D902146AF0BB7F47AFE61FBD2B2;
SET-COOKIE:YS-TAB:ENTRANCE:E=ABC;
"""
def set (self, key, Val, Coded_val, legalchars=cookie._legalchars+ ': ', Idmap=string._idmap, translate=string.translate ):
Return super (Morselhook, self). Set (Key, Val, Coded_val, Legalchars, Idmap, translate)
Cookie.morsel = Morselhook
# Let the above code execute once where you need to use cookies
if __name__ = = ' __main__ ':
Import Doctest
Doctest.testmod ()