如何将输入资本化?

2024-09-29 23:19:59 发布

您现在位置:Python中文网/ 问答频道 /正文

下面的代码,就是我希望它大写的代码。意思是一旦用户将答案输入车牌,我希望它以大写字母输出:

ask2 = ""
    plate = ""
    if int(ask) == 1:
        stop = False
        time.sleep(0.5)
        print("========================================================================")
        while not stop:
            ask2 = input("Please enter it in such form (XX00XXX): ").lower()
            valid = re.compile("[a-z][a-z]\d\d[a-z][a-z][a-z]\Z")
                                # b will start and end the program, meaning no more than 3-4 letters will be used.
            # The code which tells the user to enter the right format (keeps looping)
            # User can exit the loop by typing 'exit'
            # This is the default exit_message
            exit_message = "Verification Failed!"
            while (not valid.match(ask2)) and (ask2 != 'exit'):
                time.sleep(0.5)
                print("========================================================================\n", exit_message,
                      sep="")
                print("You can exit the validation by typing 'exit'.")
                time.sleep(0.5)
                print("========================================================================")
                time.sleep(0.5)
                ask2 = input("Or stick to the rules, and enter it in such form (XX00XXX): ").lower()
                if ask2 == 'exit':
                    exit_message = "Verification Stopped!"
                    stop = True
                    break

我已经构建了一个代码,使其大写,这就是它;但是我不知道该放在哪里:

^{pr2}$

谢谢你的帮助。在


Tags: andthe代码messageiftimeexitnot

热门问题