如何制作仅在程序第一次启动时运行的设置序列

How to make a setup sequence that only runs the first time the program is started

我正在尝试制作某种设置实例(几行代码),它只在程序第一次启动时运行。我不能依赖固定目录,因为该程序将应用于不同的系统(Win 系统)。

谢谢:)

使用主函数并将此代码放在主函数的开头。

def main():
    # put your code here
    # rest of program here

if __name__ = "__main__":
    main()

我不确定这是否正是您想要的,因为您的问题非常模糊。