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))

说明前后%和后面的参数数量不对应.红色就是错误的地方。
时间: 2024-10-10 16:48:38

TypeError: not all arguments converted during string formatting的相关文章

关于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 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

Where? 运行Python程序,报错出现在这一行 return "Unknow Object of %s" % value Why? %s 表示把 value变量装换为字符串,然而value值是Python元组,Python中元组不能直接通过%s 和 % 对其格式化,则报错 Way? 使用 format 或 format_map 代替 % 进行格式化字符串 出错代码 def use_type(value): if type(value) == int: return "i

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 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 fm

String Formatting in C#

原文地址 http://blog.stevex.net/string-formatting-in-csharp/ When I started working with the .NET framework, one thing puzzled me. I couldn’t find sprintf(). sprintf() is the C function that takes an output buffer, a format string, and any number of argu

statsmodels.tsa.arima_model预测时报错TypeError: int() argument must be a string, a bytes-like object or a number, not &#39;Timestamp&#39;

在 python 中用 statsmodels创建 ARIMA 模型进行预测时间序列: import pandas as pd import statsmodels.api as sm df = pd.read_csv("data.csv", index_col=0, parse_dates=True) mod = sm.tsa.statespace.SARIMAX(df['price'], enforce_stationarity=False, enforce_invertibili

TypeError at /admin/booktest/bookinfo/ expected string or buffer

问题描述: Request Method: GETRequest URL: http://127.0.0.1:8000/admin/booktest/bookinfo/Django Version: 1.8.2Exception Type: TypeErrorException Value: expected string or bufferException Location: /home/python/.virtualenvs/h1/local/lib/python2.7/site-pack

【python】判断年份是否为闰年

1.计算今年是闰年嘛?判断闰年条件, 满足年份模400为0, 或者模4为0但模100不为0. 代码如下: 1 x = int(raw_input('please enter a year:')) 2 if x % 4 == 0 and x % 100 != 0: 3 print 'yes' 4 elif x % 400 == 0: 5 print u"yes" 6 else: 7 print u"no" 关键点: 1.sublime text 2中需要加载subli