TypeError: unsupported operand type(s) for -: 'str' and 'int' [Python]

TypeError: unsupported operand type(s) for -: 'str' and 'int' [Python]

为什么这个错误一直出现?我只是想创建一个 table。 代码如下:

import datetime


q= datetime.date(2004,12,25)

e= datetime.date(2019,11,23) 

f= datetime.date(2019,11,26)

p= datetime.date(2004,12,13)

nam=[["attack on titan",10,"completed",p,q],["one punch man",10,"WATCHING",e,f]]

print("|         NAME           | SCORE |   STATUS   |  DATE STARTED  |    DATE ENDED   |") 

for KI in nam:
  print("|",KI[0]," "*22-len(KI[0]),"|"," ",KI[1]," ","|",KI[2]," "*(10-len(KI[2])),"|",""*2,KI[3], 
         " "*2,"|"," "*3,KI[4]," "*2,"|")

不要太在意space乘法。

错误:

|         NAME           | SCORE |   STATUS   |  DATE STARTED  |    DATE ENDED   |


Traceback (most recent call last):


    line 9, in <module>

    print("|",KI[0]," "*22-len(KI[0]),"|"," ",KI[1]," ","|",KI[2]," "*(10-len(KI[2])),"|"," "*2,KI[3]," "*2,"|"," "*3,KI[4]," "*2,"|")


TypeError: unsupported operand type(s) for -: 'str' and 'int'
.........................................................................................               

错误发生在 " "*22-len(KI[0])
" "*22是一个由22个空格组成的字符串,len(KI[0])是一个整数。
正如 TypeError 告诉您的那样,从字符串中减去一个整数没有意义。
我猜你的意图是 " "*(22-len(KI[0])).