相关疑难解决方法(0)

Python:Logging TypeError:并非在字符串格式化过程中转换所有参数

这就是我在做的事情

>>> import logging
>>> logging.getLogger().setLevel(logging.INFO)
>>> from datetime import date
>>> date = date.today()
>>> logging.info('date={}', date)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 846, in emit
    msg = self.format(record)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 723, in format
    return fmt.format(record)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 464, in format
    record.message = record.getMessage()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 328, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file <stdin>, line 1
>>> 
Run Code Online (Sandbox Code Playgroud)

我的python版本是

$ python --version
Python …
Run Code Online (Sandbox Code Playgroud)

python logging string-formatting

32
推荐指数
4
解决办法
3万
查看次数

标签 统计

logging ×1

python ×1

string-formatting ×1