小编roc*_*uff的帖子

在赋值之前可能会引用局部变量 - Python

我一直在尝试制作加密和解密系统,但我遇到了一个小错误.这是我的代码:

    import sys
    import pyperclip


    def copy(data):
        question = input("Copy to clipboard? ")

        if question.lower() == 'yes' or question.lower() == 'y':
            pyperclip.copy(data)
            print("Encrypted message copied to clipboard.")
            rerun()

        elif question.lower() == 'no' or question.lower() == 'n':
            rerun()

        else:
            print("You did not enter a valid input.")
            copy(data)


    def rerun():
        ask = input("\nWould you like to run this program again? ")

        if ask.lower() == "yes" or ask.lower() == "y":
            print(" ")
            run()

        elif ask.lower() == 'no' or ask.lower() == 'n':
            sys.exit("\nThank you!") …
Run Code Online (Sandbox Code Playgroud)

python encryption function local-variables python-3.x

2
推荐指数
2
解决办法
8495
查看次数