微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 config.ini 文件加载后跳过多行代码?

如何解决如何在 config.ini 文件加载后跳过多行代码?

所以,我正在编写一个 Python 脚本,我有一些代码询问用户是否要加载该配置文件

from configparser import ConfigParser

config = ConfigParser()

    if os.path.exists("path\\to\\config.ini"):
        load_save = input("Would you like to load your configuration (Y or N): ")
        if load_save == "Y":
            config.read("config.ini")

            delay = config.get("","")
            s_key = config.get("","")
            e_key = config.get("","")
            button = config.get("","")

但现在我想要剩下的代码

a = float(input("input: "))
    a = a

    b = input("input: ")
    b = KeyCode(char=b)

    c = input("input: ")
    c = KeyCode(char=c)

    button = input("""input.

1) 1
2) b

Choice: """)
    if button == '1':
        button = Button.left
    elif button == '2':
        button = Button.right
    else:
        pass

    save_config = input("Would you like to save the configuration (Y or N): ")
    if save_config == "Y":
        config.read("config.ini")
        config.add_section("Configuration")
        config.set("","",f"{}")
        config.set("",f"{}")
        if button == Button.left:
            config.set("",f"{}")
        elif button == Button.right:
            config.set("",f"{}")

        with open("config.ini","w") as f:
            config.write(f)
    else:
        pass

被跳过(它不在 while 循环中)。可以吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。