当我运行第一个函数时,它会输出正确的URL。但是,当我运行第二部分时,它会显示一条错误,指出未定义fullurl。
任何人都可以帮我吗?
这是我的代码:
def urlmaker(format_mtg):
fullurl = url + format_mtg.get() + "-constructed-league-" + date.get() #adds the users options to the url
print(fullurl)
return fullurl
def htmltotxt(fullurl):
print(fullurl)
response = urllib.request.urlopen(fullurl) #requests the ability to open the website, which magic.wizards.com allows
html = response.read() #reads the html data from the open website
html = str(html) #saves the data as a string
make_lists(card_name_regex, card_number_regex, card_number_list, html)
答案 0 :(得分:1)
您的代码没有注释,并且有适当的缩进和间距:
def urlmaker(format_mtg):
fullurl = url + format_mtg.get() + "-constructed-league-" + date.get()
print(fullurl)
return fullurl
def htmltotxt(fullurl):
print(fullurl)
response = urllib.request.urlopen(fullurl)
html = response.read()
html = str(html)
make_lists(card_name_regex, card_number_regex, card_number_list, html)
urllib
。url
,date
,card_name_regex
,card_number_regex
,card_number_list
。 date
甚至可能不是变量,而是导入的东西。定义它们的值或给出一个示例值,以便我们可以重现您的错误。format_mtg
和fullurl
参数的值。我可以推断出你使用第一个函数的结果作为第二个函数的参数,但仍在测量format_mtg
。如果没有这四件事,我们就无法找到您的问题。