在 Getting things gnome 代码库中,我偶然发现了这个 import 语句
from GTG import _
不知道这是什么意思,在文档中从未见过这个,所以/谷歌快速搜索没有找到任何东西。
最佳答案
from GTG import _
将 _
函数从 GTG
模块导入“当前”命名空间。
通常,_
函数是gettext.gettext()
的别名。 ,一个显示给定消息的本地化版本的函数。该文档给出了一个很远很远的模块中其他地方通常发生的事情的图片:
import gettext
gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')
gettext.textdomain('myapplication')
_ = gettext.gettext
# ...
print _('This is a translatable string.')
关于python - "from MODULE import _"在 python 中做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2908444/