c.execute("select * from Cases")
k = c.fetchall()
for l in k:
c.execute("SELECT * FROM Cases where CaseName = '%s'" % str(self.CASE_NAME.get()))
l = c.fetchone()
# these are total quantities
bar = l[2] * 24
foo = l[6]
if bar + foo == 0:
print('Out of Stock!!')
if int(self.CASE_QUANTITY.get()) > bar + foo:
print('Stock less than value given \n Provide smaller quantity.')
if foo == 0:
print('zero')
total = bar - int(self.CASE_QUANTITY.get())
print(total)
# dividing and splitting
div = divmod(total, 24)
print(div)
print(div[0])
print(div[1])
case = div[0]
piece = div[1]
c.execute("update Cases set CaseQuantity =%s and Piece= %s WHERE CaseName = %s",
(int(case, int(piece)), self.CASE_NAME.get()))
print('success')
else:
total2 = (foo + bar) - int(self.CASE_QUANTITY.get())
# diving and splitting
div2 = divmod(total2, 24)
print(div2)
print(div2[0])
print(div2[1])
case1 = div2[0]
piece1 =div2[1]
c.execute("update Cases set CaseQua"
"ntity =%s and Piece=%s WHERE CaseName = %s",
(case1, int(piece1), self.CASE_NAME.get()))
print('success')
1箱等于24块。因此,当用户请求分块产品时,代码将用24来乘以将其转换为分块,然后减去请求的分块。然后模数被用来将棋子转换成格。例如,假设有20种情况。下面将进行计算。20 * 24。如果用户要求5件。{5}(20 * 24)。转换为案例divmode((20*24)-5)。索引0上的整数被更新为案例数量。第二个索引上的整数更新到数据库表中的块,例如[19,7]。下面的错误出现每次我运行的代码:在选择
(int(case, int(piece)), self.CASE_NAME.get()))
TypeError: int() can't convert non-string with explicit base
问题来源StackOverflow 地址:/questions/59466989/typeerror-int-cant-convert-non-string-with-explicit-base-in-python-and-mysql
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。