【问题标题】:Im having trouble using the time package我在使用时间包时遇到问题
【发布时间】:2015-04-18 14:29:37
【问题描述】:

每当我使用 time 包时,我都会收到此错误:

Traceback (most recent call last):
  File "C:\Python34\2015\intrest calculator.py", line 53, in <module>
    time.sleep(1)
AttributeError: 'float' object has no attribute 'sleep'

这是我的代码:

    import time 

    while True:
        choice = input("will you like to calculate simple or compound intrest:")
        if choice == "simple intrest":
            userData(choice)
            time = time/12 
            intrest = principal * time * intrestRate
            intrest = round(intrest, 2)
            balance = principal + intrest
            balance = round(balance, 2) 
            balance = str(balance)
            intrest = str(intrest)
            print("your intrest is: %" + intrest) 
            time.sleep(1)  

            print("your final balance is $" + balance)

【问题讨论】:

    标签: time python-3.x


    【解决方案1】:

    抱歉各位,刚刚发现我的错误。

    对于遇到相同问题的其他人,请确保您的变量与您的任何包都不相同。

    对不起,这是我的错。

    应该从一开始就看到了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-23
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多