NameError: name 'requests' is not defined ?

水静流深 1248283536 at qq.com
Mon Jul 28 05:52:03 CEST 2014


there is a simple file `mydown.py`  saved in `D:\Python34\Lib\site-packages`
 there is only one line in mydown.py .
 
 import requests  
 
  
 
 C:\Users\pengsir>d:\Python34\python
 Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AM
 D64)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import mydown
 >>> dir(mydown)
 ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
 '__package__', '__spec__', 'requests']
 >>> url='http://quote.eastmoney.com/hk/02222.html?StockCode=02222'
 >>> requests.get(url)
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 NameError: name 'requests' is not defined
 
 why it run into   "NameError: name 'requests' is not defined"?‍
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140728/b993ece7/attachment.html>


More information about the Python-list mailing list