Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:not': 0.03; 'win32': 0.03; "subject:' ": 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; "'__doc__',": 0.16; "'__file__',": 0.16; '(am': 0.16; 'nameerror:': 0.16; 'skip:` 30': 0.16; 'subject:requests': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'defined': 0.27; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'requests': 0.31; "skip:' 10": 0.31; '"",': 0.31; '>>>>': 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'run': 0.32; '(most': 0.33; 'received:google.com': 0.35; 'there': 0.35; 'skip:[ 10': 0.38; 'pm,': 0.38; 'recent': 0.39; 'simple': 0.61; 'name': 0.63; 'more': 0.64; 'mar': 0.68; 'subjectcharset:utf-8': 0.72; 'jul': 0.74; '2014,': 0.84; 'url:hk': 0.84; 'url:quote': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=Sa+iCk3snaSuKJdGBiD37opzasT0bmvZPSM1H9llK7k=; b=x3MaVR5lGzoFZKKRQgpuDfgsx3McCYt2J5I/cMckcHqaYHaCNW//yqYv10FULGNwfC ZR1E36z00KJH+OhEi/PJVU5QmeCd/27N6eMmFT7sqiLDX+jcS26jobdMPX2K+IdUZyBf OgQyhwIkvWX350ckbhmjnx0Zyhmnm3Cz/qEXDyRtJSVaAPS2iUYT7mZeSzG+TmYs301w zumg/JznViujdtTdN41cmlyySeNt2KbAbyOoY04D5AMwWuKhNPRX+JtCgYToHEgJTYXc qRN4C0oRyojTtwg+2JpTfsoaKKIHAfrrm+HjDFjPG/giNL5EoHu9XFmzn7wYD2rxxlCc N3Qg== MIME-Version: 1.0 X-Received: by 10.236.31.135 with SMTP id m7mr8743874yha.104.1406521436530; Sun, 27 Jul 2014 21:23:56 -0700 (PDT) In-Reply-To: References: Date: Sun, 27 Jul 2014 21:23:56 -0700 Subject: =?UTF-8?Q?Re=3A_NameError=3A_name_=27requests=27_is_not_defined_=EF=BC=9F?= From: Dan Stromberg To: =?UTF-8?B?5rC06Z2Z5rWB5rex?= <1248283536@qq.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406521444 news.xs4all.nl 2978 [2001:888:2000:d::a6]:37540 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75295 On Sun, Jul 27, 2014 at 8:52 PM, =E6=B0=B4=E9=9D=99=E6=B5=81=E6=B7=B1 <1248= 283536@qq.com> wrote: > there is a simple file `mydown.py` saved in `D:\Python34\Lib\site-packag= es` > 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=3D'http://quote.eastmoney.com/hk/02222.html?StockCode=3D02222' >>>> requests.get(url) > Traceback (most recent call last): > File "", line 1, in > NameError: name 'requests' is not defined > > why it run into "NameError: name 'requests' is not defined"?=E2=80=8D Perhaps try "mydown.requests.get(url)"?