以下代码以前对我有效,应该根据文档工作:
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging.handlers
>>> logging.handlers.WatchedFileHandler("log.log")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'WatchedFileHandler'
从文件中:
^{pr2}$这可能是什么原因?在
如果有人在使用python3时遇到了相同的问题,可以通过如下方式分别导入}来解决
logging.handlers
和{日志记录是由
pip
或easy_install
手动安装的,但是pip中的包比较旧,因此我在/usr/local/lib/python2.7/dist-packages
中安装了0.4.9.6版本,而最新的版本是在usr/lib/python2.7
中随python一起安装的。在服务器上,dist-package
似乎位于路径的前面,但不在桌面上。无论如何,删除旧的包解决了这个问题。在相关问题 更多 >
编程相关推荐