TypeError: not enough arguments for format string

Error msg:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/__init__.py", line 993, in emit
    msg = self.format(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 839, in format
    return fmt.format(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 579, in format
    s = self.formatMessage(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 548, in formatMessage
    return self._style.format(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 391, in format
    return self._fmt % record.__dict__
TypeError: not enough arguments for format string
Call stack:
  File "start.py", line 7, in <module>
    Engine().start()
  File "/home/hpcm/Desktop/spider/13-frame_spider/myscrapy/core/engine.py", line 45, in start
    logger.info("End time is [ {} ]".format(end))
Message: ‘End time is [ 2018-09-27 17:55:54.795786 ]‘
Arguments: ()

问题:

  setting中的log使用的DEFAULT_LOG_FMT参数出错

解决:

  检查参数是否写错, 或者多项少项

原文地址:https://www.cnblogs.com/hpcm/p/9779931.html

时间: 2024-10-10 16:48:32

TypeError: not enough arguments for format string的相关文章

Python TypeError: not enough arguments for format string

今天使用mysqldb执行query语句的时候,在执行这条语句的时候: select PROJ, DATE_FORMAT(MAX(DATE),'%Y-%m-%') AS MAXDATE, DATE_FORMAT(MIN(DATE),'%Y-%m-%d') AS MINDATE FROM (SELECT resource.PROJ,`day`.DATE FROM resource,`day` where resource.MAC=`day`.MAC ORDER BY PROJ) AS PROJSE

TypeError not all arguments converted during string formatt

1.错误描述 >>> a=1; >>> b=1; >>> for i in range(1,21): print('121d %121d' % (a,b)); if(i%3==0): a=a+b ; b=a+b; Traceback (most recent call last): File "<pyshell#23>", line 2, in <module> print('121d %121d' % (a

关于Python的TypeError not all arguments converted during string formatting

前言 在把yolov3的cfg文件转换为model_defs时,我忘记把str类型转换成int了,导致了一个错误,在此记录下来. 正文 如上图所示,'32'%2就是错误发生的地方. 我以为我拿到的是一个int类型的32,想判断它是偶数还是奇数. 实际上我拿到的是一个str类型的'32',这时python的解释器并没有把%理解成取余,而是理解成了这种东西. 我不知道"这种东西"的定义,但知道其用法和语法,其语法是这样的: name = 'cxy' print('%s is handsom

TypeError: not all arguments converted during string formatting

print ("So, you're 5r old, %r tall and %r heavy." % (age, height, weight)) print ("So, you're %r old, %r tall and %r heavy." % (age, height, weight)) 说明前后%和后面的参数数量不对应.红色就是错误的地方.

字符串模版替换的方法MessageFormat.format(String pattern, Object ... arguments)

MessageFormat.format(String pattern, Object ... arguments) MessageFormat.format(NewOrderConstant.PAY_SCHEMA, URLEncoder.encode(MessageFormat.format(NewOrderConstant.RESULT_SCHEME, String.valueOf(orderId)), HTTP.UTF_8), URLEncoder.encode(MessageFormat

String.format(String format, Object... args)方法详解

很多次见到同事使用这个方法,同时看到https://blog.csdn.net/qq_27298687/article/details/68921934这位仁兄写的非常仔细,我也记录一下,好加深印象. 这个是从java5的时候添加进去的方法. /** * Returns a formatted string using the specified format string and * arguments. * * <p> The locale always used is the one r

解决sqoop 导入oracle表时 --split-by参数为日期类型时的报错:ORA-01861: literal does not match format string

报错栈: 2017-06-08 18:46:13,422 INFO [main] org.apache.sqoop.mapreduce.db.DBRecordReader: Executing query: select "JFRQ","ZYH","FYKS","KSSE","YBJE","YPJE","ZJJE" from BSHIS."DEPCS_T_D

Predicate Format String Syntax 与字面量

字面量: 字符串:单引号或双引号扩起来: %@:系统自动添加,数字则自动去除@(): 无单双引号,系统做数字处理. Single or double quoting variables (or substitution variable strings) cause %@, %K, or $variable to be interpreted as a literal in the format string and so prevent any substitution. 系统自动添加   d

Oracle问题之literal does not match format string

问题: oerr ora 186101861, 00000, "literal does not match format string"// *Cause: Literals in the input must be the same length as literals in// the format string (with the exception of leading whitespace). If the// "FX" modifier has bee