当我在 while 循环中使用 GOTO 命令时它不起作用

问题描述

我正在尝试制作一个选择系统。我想使用 GOTO 命令。但它实际上不起作用。我已经在 pip 中安装了 goto 语句。

from goto import with_goto
print('Welcome to * sell system.')
print('Choose the action:\n(1) Buy *\n(2) Contact us\n(3) Exit')
# Choose the action
while action := input('> '):
    if action in '1':
        break
    if action in '2':
        print('Contact Us\n* is a brand of *')
        break
    if action in '3':
        exit()
    print('Only 1 and 2 allowed.') 
# Choose the categories
if action in '1':
    print('Choose categories of merchandises.\n(1) *\n(2) *')
    print('Enter 0 to exit') 
# Choose the merchandise (A while in a if)   
    while category := input('> '):
        if category in '1':
            label .choose_merchandises
            print('Choose the merchandises.\n(1) *- *')
            while merchandises := input('> '):
                if merchandises in '1':
                    print('Title:*- *\nPrice: *\nAmount: *\nDetails:\nDo you wanna buy it?\n(y/n)')
                    while wannabuy := input('> '):
                        if wannabuy == "y":
                            print('Redirecting to pay...')
                            break
                        if wannabuy == "n":
                            goto .choose_merchandises                    
                        print('Only y or n allowed.')
                    print ('1')
        if category in '2':
            print('2')
            break
    print('Only 1 and 2 allowed.')

它告诉我

Traceback (most recent call last):
  File "d:\*\*.py",line 18,in <module>
    label .choose_merchandises
NameError: name 'label' is not defined

我该怎么办。欣赏。

补丁: 我是python的初学者。这是一个选择系统,人们可以做他们想做的事情,比如联系我们,买东西等等。首先,用户选择买东西,联系我们这样的动作。用户选择商品类别,然后选择商品。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...