如果必要,我想在python中重复某个if语句 elif opt==2: nitem=str(输入('输入管道名称') nitemc=int(输入('输入项目代码')) nstkq=int(输入(“输入库存数量”) nitemtyp=str(输入('enter item type')) b={'itemname':nitem,'itemcode':nitemc,'item-type':nitemtyp,'stock':nstkq} stock=stock.append(b,忽略索引=True) x=str(输入('是否要添加另一个?\n“y”表示是“n”表示否”)) 如果x=='y':

如果必要,我想在python中重复某个if语句 elif opt==2: nitem=str(输入('输入管道名称') nitemc=int(输入('输入项目代码')) nstkq=int(输入(“输入库存数量”) nitemtyp=str(输入('enter item type')) b={'itemname':nitem,'itemcode':nitemc,'item-type':nitemtyp,'stock':nstkq} stock=stock.append(b,忽略索引=True) x=str(输入('是否要添加另一个?\n“y”表示是“n”表示否”)) 如果x=='y':,python,command,keyword,Python,Command,Keyword,我应该使用什么代码使代码在用户要求的时间内重复 希望我能得到帮助谢谢 打个圈怎么样? elif opt==2: nitem=str(input('enter the porduct name')) nitemc=int(input('enter the item code')) nstkq=int(input('enter stock qty')) nitemtyp=str(input('enter item type')) b={'itemname':n

我应该使用什么代码使代码在用户要求的时间内重复


希望我能得到帮助谢谢

打个圈怎么样?
elif opt==2:
    nitem=str(input('enter the porduct name'))
    nitemc=int(input('enter the item code'))
    nstkq=int(input('enter stock qty'))
    nitemtyp=str(input('enter item type'))
    b={'itemname':nitem,'itemcode':nitemc,'item-type':nitemtyp,'stock':nstkq}
    stock=stock.append(b ,ignore_index=True)
    x=str(input('do you want to add another one? \n "y" for yes "n" for no' ))
    if x=='y':
        <to repeat>
elif opt==2:
    while True:
        nitem=str(input('enter the porduct name'))
        nitemc=int(input('enter the item code'))
        nstkq=int(input('enter stock qty'))
        nitemtyp=str(input('enter item type'))
        b={'itemname':nitem,'itemcode':nitemc,'item-type':nitemtyp,'stock':nstkq}
        stock=stock.append(b ,ignore_index=True)
        x=str(input('do you want to add another one? \n "y" for yes "n" for no' ))
        if x=='n':
            break