a = '12:13:50'
b = '12:28:21'
time_a = datetime.strptime(a,'%H:%M:%S')
time_b = datetime.strptime(b,'%H:%M:%S')
print (time_b - time_a).seconds
python 错误提示TypeError: unsupported operand type(s) for //: 'str' and 'int'是设置错误造成的,解决方法为
1、图片中没有定义numi但是print函数里面用了所以出现命令错误。
2、例中if num = 44;写成了num==44,没满足if应有的语法引起的错误。
3、例中字符串类型的数据不能相乘引起的错误。
4、python需要严格的遵循缩进缩进不正常会引起错误。
input() 返回的是键盘输入的一个字符串,需要转换成数值类型然后再相加,可以用 int() 将字符串转换成整型数值 。
例如:
A = int(input())B = int(input())
C = A + B
print(C)
# 或者
A = input()
B = input()
C = int(A) + int(B)
print(C)