0
我试图打印但是第一条语句是工作的运作,但第二条语句有错误。不支持的操作数类型“浮动”和“海峡”
conSwitch = raw_input("Enter cycle of context switch: ")
cycleOpr = raw_input("Enter cycle operation: ")
totalCycle = float(conSwitch) + float(cycleOpr) + float(conSwitch)
print "Context =", conSwitch
print "Cycle operation =", cycleOpr
print "Context switch back =", conSwitch
print("\n")
print (conSwitch + " + " + cycleOpr + " + " + conSwitch)
print ("Total number of cycle is: " + format(totalCycle))
print("===================================================")
reqSecond = raw_input("Enter cycle request second:")
print "Total cycle request =", totalCycle
print "Cycle request per second =", reqSecond
print("\n")
totalSpent = float(totalCycle) * float(reqSecond)
print (totalCycle + " * " + reqSecond)
print ("Total number of spent = " + format(totalSpent))
=========================================== ===================
First statement
Work===>> print (conSwitch + " + " + cycleOpr + " + " + conSwitch)
Second statement
Error===>> print (totalCycle + " * " + reqSecond)
打印( “总数花= {0}”。格式(totalSpent))或“总周期请求= {0}”。格式(totalCycle) –
我想这是因为你试图连接具有一个字符串浮动。尝试'打印(STR(totalCycle)+ “*” + STR(reqSecond))' – LismUK