gpt4 book ai didi

python - 如何修复 python 中的错误 "illegal target for annotation"?

转载 作者:行者123 更新时间:2023-12-01 06:50:57 28 4
gpt4 key购买 nike

我正在学习Python,这个程序运行得很好,但是突然我从第33行的:到程序末尾出现了一条红线,并显示错误“非法注释目标”。我该如何解决这个问题?

import turtle
import decimal
from decimal import Decimal
import sys
account_1_name = "John Smith"
account_1_balance = "67.58"
account_1_vault_balance = "200.00"
style = ('Calibri', 30)
password = input("What is your password?")
if password == "Cryptic":
turtle.hideturtle()
turtle.bgcolor("green")
turtle.write("Access Granted.", font=style)
turtle.done()
prompt = input("""
Welcome to Bank Network.

Hello, %s
Your balance is $%s
Your savings account balance is $%s.

type transfer to transfer money to savings section.
type deposit to deposit a check.""" % (account_1_name, account_1_balance , account_1_vault_balance))
if prompt == "deposit":
print("deposit system is down right now. Please try again later.")
sys.exit(0)
if prompt == "transfer":
transfer_amount = input("How much do you want to transfer?")
transfer_prompt = input("""
are you sure you want to transfer money to your savings section?
type cancel to cancel.
type confirm to transfer"""
if transfer_amount > account_1_balance:
print("Not enough balance.")
if transfer_amount < account_1_balance:
print("Ok. Money transfered.")
balance_post_transfer = Decimal(account_1_balance) - Decimal(transfer_amount)
account_1_vault_balance_post_transfer = Decimal(account_1_vault_balance) + Decimal(transfer_amount)
print("Your balance is now $%s and your savings account balance is $%s" % (balance_post_transfer, account_1_vault_balance_post_transfer))
if password != ("Cryptic"):
turtle.hideturtle()
print("access denied.")
turtle.bgcolor("red")
turtle.write("access denied.", font=style)
turtle.done()

最佳答案

从第 29 行到第 32 行,您有:

transfer_prompt = input("""
are you sure you want to transfer money to your savings section?
type cancel to cancel.
type confirm to transfer"""

您没有关闭输入。这就是你的错误的原因。将这些行替换为:

transfer_prompt = input("""
are you sure you want to transfer money to your savings section?
type cancel to cancel.
type confirm to transfer""")

关于python - 如何修复 python 中的错误 "illegal target for annotation"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59005237/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com