我如何修复错误;注释的目标不合法";用python?
我正在学习Python,这个程序运行得很好,但突然我从:第33行到程序末尾有一条红线,错误是“非法的注释目标”。我怎样才能解决这个问题我如何修复错误;注释的目标不合法";用python?,python,Python,我正在学习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', 3
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()
导入海龟
输入小数
从十进制输入十进制
导入系统
账户名称=“约翰·史密斯”
账户1\u余额=“67.58”
账户1保险库余额=“200.00”
风格=('Calibri',30)
密码=输入(“您的密码是什么?”)
如果密码==“神秘”:
乌龟
海龟。绿色(“绿色”)
write(“授予访问权限”,font=style)
乌龟
提示=输入(“”)
欢迎来到银行网络。
您好,%s
您的余额是$%s
您的储蓄账户余额为$%s。
键入“转账”将钱转账到“储蓄”部分。
键入存款以存入支票。“%”(账户名称、账户余额、账户余额)
如果提示==“存款”:
打印(“存款系统正在关闭。请稍后再试。”)
系统出口(0)
如果提示==“传输”:
转账金额=输入(“您想转账多少?”)
传输提示=输入(“”)
你确定要把钱转到储蓄部吗?
键入cancel以取消。
键入确认以传输“”
如果转账金额>账户余额:
打印(“余额不足”)
如果转账金额<账户余额:
打印(“好的,钱转移了。”)
余额\转账后\转账=小数(科目\余额)-小数(转账金额)
科目1保管库余额过户=小数(科目1保管库余额)+小数(过户金额)
打印(“您现在的余额为$%s,您的储蓄账户余额为$%s”%(余额\过账\转账、账户\ 1 \金库\余额\过账))
如果密码!=(“神秘”):
乌龟
打印(“访问被拒绝”)
海龟。颜色(“红色”)
write(“访问被拒绝”,font=style)
乌龟
从第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""")
如果在一行代码的末尾有一个“:”而不应该是,则也会出现此错误。:) 如果name='main': 写入序列(filename='C:\Python\File\IO\recaman.txt',num=0) 如果是这样,就会出现错误。我养成了这样的习惯,如果看起来需要采取行动,我会把这个扔到队伍的末尾。 如果name='main': 写入序列(filename='C:\Python\File\IO\recaman.txt',num=0):