我正在编写一些代码,包括将变量与数字相乘。这是似乎破坏的代码:
CREATE TRIGGER `UpdateReservation_paid` AFTER INSERT OR UPDATE ON `Payment`
FOR EACH ROW BEGIN
AS
begin
update Reservation
SET Reservation_paid='YES'
Where NEW.ClientID = Reservation.ClientID
and NEW.ReservationID = Reservation.ReservationID
end
当我运行脚本时,说var2是3,它应该返回 3 3150 但它返回:
print (var2)
var1 = var2 * 1050
print(var1)
input("Press Enter to continue...")
答案 0 :(得分:13)
问题是var2
是一个字符串。将*N
应用于字符串会产生返回原始字符重复N
的字符串的效果。例如
>>> s = '123'
>>> s * 3
'123123123'
您需要将var2
转换为数字类型,可能是整数。例如,
>>> int(s) * 3
369