2014-05-14 3 views
2

urllib을 Python 3.4 설치에 사용할 수없는 이유는 무엇입니까?urllib에 누락 된 메서드

내가 가져올 수 있습니다,하지만 난 어떤 방법을 사용할 수 없습니다

Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)] on win32 
Type "copyright", "credits" or "license()" for more information. 
>>> import urllib 
>>> dir(urllib) 
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__'] 

편집 :

내가 볼 수없는 하위 모듈 중 하나를

>>> dir(urllib.request) 
Traceback (most recent call last): 
    File "<pyshell#2>", line 1, in <module> 
    dir(urllib.request) 
AttributeError: 'module' object has no attribute 'request' 
>>> 
+1

먼저'urllib.request'을 가져와야는 다음에 dir''전화 : 파이썬 3.x의에서 urllib의 여러 하위 모듈이 있습니다. – dano

답변

3

dir이 오해입니다 당신. https://docs.python.org/3.4/library/urllib.html

>>> import urllib 
>>> dir(urllib) 
['__builtins__', '__cached__', '__doc__', '__file__', '__name__', '__package__', '__path__'] 
>>> import urllib.request 
>>> dir(urllib.request) 
['AbstractBasicAuthHandler', 'AbstractDigestAuthHandler', 'AbstractHTTPHandler', 'BaseHandler', 'CacheFTPHandler', 'ContentTooShortError', 'FTPHandler', 'FancyURLopener', 'FileHandler', 'HTTPBasicAuthHandler', 'HTTPCookieProcessor', 'HTTPDefaultErrorHandler', 'HTTPDigestAuthHandler', 'HTTPError', 'HTTPErrorProcessor', 'HTTPHandler', 'HTTPPasswordMgr', 'HTTPPasswordMgrWithDefaultRealm', 'HTTPRedirectHandler', 'HTTPSHandler', 'MAXFTPCACHE', 'OpenerDirector', 'ProxyBasicAuthHandler', 'ProxyDigestAuthHandler', 'ProxyHandler', 'Request', 'URLError', 'URLopener', 'UnknownHandler', '__builtins__', '__cached__', '__doc__', '__file__', '__name__', '__package__', '__version__', '_cut_port_re', '_ftperrors', '_have_ssl', '_localhost', '_noheaders', '_opener', '_parse_proxy', '_proxy_bypass_macosx_sysconf', '_safe_gethostbyname', '_thishost', '_urlopener', 'addclosehook', 'addinfourl', 'base64', 'bisect', 'build_opener', 'collections', 'email', 'ftpcache', 'ftperrors', 'ftpwrapper', 'getproxies', 'getproxies_environment', 'hashlib', 'http', 'install_opener', 'io', 'localhost', 'noheaders', 'os', 'parse_http_list', 'parse_keqv_list', 'pathname2url', 'posixpath', 'proxy_bypass', 'proxy_bypass_environment', 'quote', 'random', 'randombytes', 're', 'request_host', 'socket', 'splitattr', 'splithost', 'splitpasswd', 'splitport', 'splitquery', 'splittag', 'splittype', 'splituser', 'splitvalue', 'ssl', 'sys', 'thishost', 'time', 'to_bytes', 'unquote', 'unwrap', 'url2pathname', 'urlcleanup', 'urljoin', 'urlopen', 'urlparse', 'urlretrieve', 'urlsplit', 'urlunparse'] 
+0

답변을 주셔서 감사합니다,하지만 하위 모듈 중 하나를 볼 수 없습니다. – stenci

+0

@stenci 실제 가져 오기가 실패합니까? – dano

+0

가져 오기 오류 메시지를 제공합니다. 게시물의 출력물이 유휴 상태에서 완전히 복사됩니다. – stenci

관련 문제