python 3.2错误提示urllib.parse.urlencode()未定义。

9 浏览
0 Comments

python 3.2错误提示urllib.parse.urlencode()未定义。

我正在尝试在我的脚本中使用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 
    data = urllib.parse.urlencode({'type': 'device_code','client_id': 150792241632891})
AttributeError: 'module'对象没有'parse'属性

起初我怀疑是我的Python shell的问题,但当我检查时,它正在使用Python 3.2版本,应该没问题。

现在我完全困惑了,为什么Python shell会表现出这种方式。

我错过了什么吗?

谢谢

0