未知错误,RSS提要 [英] Unknown errors, RSS feed

查看:84
本文介绍了未知错误,RSS提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的另一篇文章中,我正在制作一个用Python创建RSS源的简单程序。现在,当我运行我的程序到目前为止,我得到错误。它说某些东西没有定义。这个词被我正在尝试使用的函数的名称所取代。我的文章功能在运行时,出现文章未定义等等


这是我的代码:它有什么问题?

From my other post I am making a simple program that creates an RSS feed with Python. Now when I run my program so far, I get errors. It says "something is not defined". The word something is replaced by the name of the function I''m trying to use. my article function when ran, comes up with "article is not defined" etc.

Here''s my code: What is wrong with it?

展开 | 选择 | Wrap | 行号

推荐答案

在这一行:
展开 | 选择 | Wrap | 行号


以下是我到目前为止所遇到的错误:


否1:
Here are the errors I get so far:

No 1:
展开 | 选择 | Wrap | 行号


这是范围问题, Python解析名称的方式。函数执行时,会创建一个新的命名空间,其中包含函数中指定的函数参数和变量的名称。解析名称时,解释器首先检查本地名称空间,在本例中,检查函数创建的名称空间。如果未找到匹配项,则会检查全局命名空间。全局命名空间始终是定义函数的模块。如果未找到匹配项,则会在引发NameError异常之前检查内置命名空间。如您所见,解释器从不检查模块中其他函数的名称空间。您必须使变量名称为全局变量或将参数传递给函数。
It is a matter of scope and the way Python resolves names. When a function executes, a new namespace is created which includes the names of the function parameters and variables assigned in the function. When resolving names, the interpreter first checks the local namespace, in this case, the namespace created by the function. If no match is found, it checks the global namespace. The global namespace is always the module which defines the function. If no match is found, it checks the built-in namespace before raising a NameError exception. As you can see, the interpreter never checks the namespaces of the other functions in your module. You must make the variable names global or pass arguments to your functions.


这篇关于未知错误,RSS提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆