Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75295

Re: NameError: name 'requests' is not defined ?

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 <drsalists@gmail.com>
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 <tencent_0C4197AD5C3B99803D5DA2BB@qq.com>
References <tencent_0C4197AD5C3B99803D5DA2BB@qq.com>
Date Sun, 27 Jul 2014 21:23:56 -0700
Subject Re: NameError: name 'requests' is not defined ?
From Dan Stromberg <drsalists@gmail.com>
To 水静流深 <1248283536@qq.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12375.1406521444.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Jul 27, 2014 at 8:52 PM, 水静流深 <1248283536@qq.com> wrote:
> 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"?‍

Perhaps try "mydown.requests.get(url)"?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: NameError: name 'requests' is not defined ? Dan Stromberg <drsalists@gmail.com> - 2014-07-27 21:23 -0700

csiph-web