Discuss / Python / bh打卡day5

bh打卡day5

路由跳变

#1 Created at ... [Delete] [Delete and Lock User]

args = ['gcc', 'hello.c', 'world.c']

# args = ['clean']

# args = ['gcc']

match args:

    # 如果仅出现gcc,报错:

    case ['gcc']:

        print('gcc: missing source file(s).')

    # 出现gcc,且至少指定了一个文件:

    case ['gcc', file1, *files]:

        print('gcc compile: ' + file1 + ', ' + ', '.join(files))

    # 仅出现clean:

    case ['clean']:

        print('clean')

    case _:

        print('invalid command.')


  • 1

Reply