【问题标题】:TypeError: unsupported operand type(s) for *: 'module' and 'int'TypeError: *: 'module' 和 'int' 的不支持的操作数类型
【发布时间】:2022-06-11 00:19:29
【问题描述】:

我还是 Python 新手,如果这是一个荒谬的问题,那么抱歉。我正在尝试将此模块作为“速率”导入,但标题中不断出现错误。任何 cmets 都会有所帮助。

def pay(r, h):
    total = r * h
    return total

def over(ra, hs):
    over_time = ra * 40 + (ra * 1.5 * ( hs - 40))
    print(f'{over_time} is')

这是主要代码:

import rate



def main():
    calc()
    calc()
    calc()

def calc():

    name = input('Enter employee name: ')
    rates = int(input(f'Enter hourly rate for {name}: '))
    hours = int(input(f'Enter hours for {name} this week: '))
    if rates <= 40:
        p = rate.pay(rate, hours)
        print(f'Pay for {name} is ${p:,.2f}')
    else:
        rate.over(rate, hours)
        
if __name__ == '__main__':
    main()

【问题讨论】:

  • rate.pay(rates, hours)rate.over(rates, hours),你忘记了一封信 s

标签: python function module typeerror operands


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-27
  • 2014-03-31
  • 2012-12-12
  • 2020-02-27
  • 2021-05-23
  • 2016-04-15
  • 2019-01-12
相关资源
最近更新 更多