Python 我的代码一直在说AttributeError:';str';对象没有属性';formart&x27; salary=float(输入(“您的薪水是多少?”) 如果工资>1250.00: 新=工资*0.1 印刷(“增加额为{}”。formart(新)) 如果工资
是一个简单的打字错误,Python 我的代码一直在说AttributeError:';str';对象没有属性';formart&x27; salary=float(输入(“您的薪水是多少?”) 如果工资>1250.00: 新=工资*0.1 印刷(“增加额为{}”。formart(新)) 如果工资,python,Python,是一个简单的打字错误,formart应该是format,同样是错误的缩进: Traceback (most recent call last): File "python", line 7, in <module> AttributeError: 'str' object has no attribute 'formart' 如果版本>pytho 3.6,则为f字符串: salary = float(input("What is your salary?")) if salar
formart
应该是format
,同样是错误的缩进:
Traceback (most recent call last):
File "python", line 7, in <module>
AttributeError: 'str' object has no attribute 'formart'
如果版本>pytho 3.6,则为f字符串:
salary = float(input("What is your salary?"))
if salary > 1250.00 :
new = salary*0.1
print("the increase was %s"%(new))
if salary <= 1250.00:
new = salary*0.15
print("the increase was %s"%(new))
salary=float(输入(“您的薪水是多少?”)
如果工资>1250.00:
新=工资*0.1
打印(f“增加额为{new}”)
如果工资为1250.00:
新=工资*0.1
打印(“增加的是”,新的)
如果你的代码有输入错误。它应该是“格式”,而不是“格式”。还有糟糕的缩进。哦,谢谢。我现在修好了。
salary = float(input("What is your salary?"))
if salary > 1250.00 :
new = salary*0.1
print("the increase was {}".format(new))
if salary <= 1250.00:
new = salary*0.15
print("the increase was {}".format(new))
salary = float(input("What is your salary?"))
if salary > 1250.00 :
new = salary*0.1
print("the increase was %s"%(new))
if salary <= 1250.00:
new = salary*0.15
print("the increase was %s"%(new))
salary = float(input("What is your salary?"))
if salary > 1250.00 :
new = salary*0.1
print(f"the increase was {new}")
if salary <= 1250.00:
new = salary*0.15
print(f"the increase was {new}")
salary = float(input("What is your salary?"))
if salary > 1250.00 :
new = salary*0.1
print("the increase was", new)
if salary <= 1250.00:
new = salary*0.15
print("the increase was", new)