简体   繁体   English

TypeError: unsupported operand type(s) for /: 'tuple' and 'int' ---不理解错误

[英]TypeError: unsupported operand type(s) for /: 'tuple' and 'int' ---don't understand the error

I'm trying to run a code only I don't understand this error:我试图运行一个代码,但我不明白这个错误:

  if AC_energy / pow == 1:
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'

The piece of code:这段代码:

  Power = (5, 10, 15, 20)

  for pow in Power:

   for Hours in range(1, 6):

       AC_energy = Power * Hours

       print(AC_energy)

       if AC_energy / pow == 1:

          Rack_energy = 230

       else:
          Rack_energy = 288

       Nbr_rack = ((AC_energy *(1 + 0.2)) *1000) / Rack_energy

       Energy = ((Rack_energy * Nbr_rack)/ 1000)* 0.95

Thank you for your help:)谢谢您的帮助:)

You are multiplying a tuple with an integer at the beginning.您在开始时将一个元组与 integer 相乘。 The result is a tuple and you get an error when dividing it with an integer.结果是一个元组,在将其与 integer 相除时会出现错误。

>>> (5, 10, 15, 20) * 6
(5, 10, 15, 20, 5, 10, 15, 20, 5, 10, 15, 20, 5, 10, 15, 20, 5, 10, 15, 20, 5, 10, 15, 20)

What you might want to do is to change the line您可能想要做的是更改线路

AC_energy = Power * Hours

with

AC_energy = pow * Hours

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:不支持 / 的操作数类型:'tuple' 和 'int' - TypeError: unsupported operand type(s) for /: 'tuple' and 'int' TypeError:+不支持的操作数类型:“ int”和“ tuple” - TypeError: unsupported operand type(s) for +: 'int' and 'tuple' 类型错误:% 不支持的操作数类型:'tuple' 和 'int' - TypeError: unsupported operand type(s) for %: 'tuple' and 'int' 如何修复错误 - TypeError:不支持的操作数类型 - :'tuple'和'int' - How to fix error - TypeError: unsupported operand type(s) for -: 'tuple' and 'int' TypeError:+ =不支持的操作数类型:“ int”和“ tuple”错误 - TypeError: unsupported operand type(s) for +=: 'int' and 'tuple' error 不了解此 TypeError 的原因:不支持的操作数类型 - Don't understand cause of this TypeError: unsupported operand type(s) 试图平均一个列表,但我不知道错误是什么意思:不支持的操作数类型+:'int'和'tuple' - Trying to average a list, but I don't know what is meant by the error: unsupported operand type(s) for +: 'int' and 'tuple' 我有错误 TypeError: unsupported operand type(s) for /: 'function' and 'int' 我不知道如何修复它 - I have the error, TypeError: unsupported operand type(s) for /: 'function' and 'int' and I don't know how to fix it 获取 TypeError: 不支持的操作数类型 -: 'tuple' 和 'int' - Getting TypeError: unsupported operand type(s) for -: 'tuple' and 'int' 如何修复 Python TypeError:不支持的操作数类型“int”和“tuple” - How to fix Python TypeError: unsupported operand type(s) 'int' and 'tuple'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM