不理解此类型错误:无法连接“str”和“int”对象异常

2024-05-19 10:08:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我得到一个错误: TypeError: cannot concatenate 'str' and 'int' objects 运行下面的代码时。它涉及到年、月和日是整数,并且在引号中有引号。我的Python版本是2.7,因为我在没有管理员权限的工作计算机上工作,所以无法更新Python。你知道吗

import os

#input1 is the first date, input2 is the second date, with a 1 day
difference
yearinput1 = input("What's the start year?")
monthinput1 = input("What's the start month?")
dayinput1 = input("What's the start day?")
yearinput2 = input("What's the end year?")
monthinput2 = input("What's the end month?")
dayinput2 = input("What's the end day?")

print"sudo mam-list-usagerecords -s \" ", yearinput1, "-" , monthinput1, "-", dayinput1, " \" -e \" ", yearinput2, "-" + monthinput2, "-", dayinput2, " \" --format csv --full"

Tags: theinputdateisyearwhatstart引号

热门问题