我正在尝试在我的一个脚本中使用urllib.parse.urlencode()方法。
import urllib
#!/usr/bin/python3.2
import urllib
data = urllib.parse.urlencode({'type': 'device_code','client_id': 150792241632891})
之前它是可以运行的,但现在我遇到了以下错误。
输出
Traceback (most recent call last):
File "/home/rakesh/programming/test.py", line 8, in <module>
data = urllib.parse.urlencode({'type': 'device_code','client_id': 150792241632891})
AttributeError: 'module' object has no attribute 'parse'
起初我怀疑我的Python shell,但当我检查后发现它正在使用版本为3.2的Python,应该没问题。
现在我完全不明白为什么Python shell表现出这种行为。我是否漏掉了什么?
谢谢