我今天遇到了一个奇怪的问题。我在使用 Python 标准库的 string
模块的 letters
变量时注意到 bpython 中的结果与 vanilla python 中的结果不同。
我正在使用 Python 2.7.3 和 bpython 0.10.1 以及 virtualenv 1.8.4。这是我所看到的。
$ bpython
>>> import string
>>> string.letters
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
$ python
>>> import string
>>> string.letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
我不确定它是否重要,但我在 xubuntu 12.10 上运行它。
有人可以解释一下这里发生了什么吗?
最佳答案
来自docs , string.letters 定义为
The concatenation of the strings lowercase and uppercase described below. The specific value is locale-dependent, and will be updated when locale.setlocale() is called.
所以可能是您的语言环境不同。
关于python - 为什么 string.letters 在 python 和 bpython 之间不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16195144/