Python:回溯

2024-06-02 07:20:46 发布

您现在位置:Python中文网/ 问答频道 /正文

Traceback <most recent call last>:
  File "wexec.py", line 37, in <module>
   urlopen = urllib.urlopen('%xs' % (hcon))
NameError: name 'hcon' is not defined

我用python编写代码时遇到了这个问题:

def hell():

    hcon = raw_input(Fore.RED + Style.BRIGHT + "Website: ")
    h1 = httplib.HTTPConnection('%s' % (hcon))
    urlopen = urllib.urlopen('%s' % (hcon))

hell()

如你所见,我看不出有什么问题。但有些东西给了它这个错误。我该怎么办?你知道吗


Tags: inpymostlineurllibcallfileurlopen