简体   繁体   English

如何访问 Python 中的列表

[英]How do I access lists in Python

So basically I am looking to make my own terminal inside of my cmd prompt, (just a silly test, I am a beginner,) and I made a list of cmds that the user can type to use them, for example '-help'所以基本上我希望在我的 cmd 提示符中创建自己的终端,(只是一个愚蠢的测试,我是初学者,)我列出了用户可以键入以使用它们的 cmds,例如'-help'

Problem is, I don't know how to check if the user actually entered it, because I could go individually, but obviously that would take a lot of time... Here is my code:问题是,我不知道如何检查用户是否真的输入了它,因为我可以单独 go ,但显然这会花费很多时间......这是我的代码:

import random
import time

ans = False
cmds = ['help', 'h']
run = True
money = 0
items = []

time.sleep(1)

def cmd():
    if inp == cmds:
        print("Success")

while run:
    inp = input(">> ")
    cmd()

So basically I am looking to make my own terminal inside of my cmd prompt, (just a silly test, I am a beginner,) and I made a list of cmds that the user can type to use them, for example '-help'所以基本上我希望在我的 cmd 提示符中创建自己的终端,(只是一个愚蠢的测试,我是初学者,)我列出了用户可以键入以使用它们的 cmds,例如'-help'

Problem is, I don't know how to check if the user actually entered it, because I could go individually, but obviously that would take a lot of time... Here is my code:问题是,我不知道如何检查用户是否真的输入了它,因为我可以单独 go ,但显然这会花费很多时间......这是我的代码:

import random
import time

ans = False
cmds = ['help', 'h']
run = True
money = 0
items = []

time.sleep(1)

def cmd():
    if inp == cmds:
        print("Success")

while run:
    inp = input(">> ")
    cmd()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM