参考学习:http://www.blogjava.net/ashutc/archive/2011/03/21/346695.html
1.urllib.quote()函数
模拟登录时,对用户名进行处理:
1 def GetUserName(userName): 2 userNameTemp = urllib.quote(userName) 3 userNameEncoded = base64.encodestring(userNameTemp)[:-1] 4 return userNameEncoded
不理解为什么要用urllib.quote()而不用urllib.urlencode()函数,后来编码:
1 userNameTemp = urllib.urlencode(userName)
发生错误:
userNameTemp = urllib.urlencode(userName) File "C:\Python27\lib\urllib.py", line 1324, in urlencode raise TypeError TypeError: not a valid non-string sequence or mapping object
时间: 2024-10-29 19:06:41