python - How to make a setup sequence that only runs the first time the program is started
问题描述
I am trying to make some sort of a setup instance (few lines of code), that only runs first time the program is started. I can't rely on fixed directorys, since the program is going to be applied to different systems(Win systems).
Thanks :)
解决方案
Use a main function and put this code at the start of your main.
def main():
# put your code here
# rest of program here
if __name__ = "__main__":
main()
I am not sure if this is exactly what you want as your question is pretty vague.
推荐阅读
- dask - 在旧工人死亡后添加新工人时,如何重新提交 dask 工作(来自以前死去的工人)?
- flutter - 从表日历颤动中获取选定日期的值数据表
- mysql - Mysql 5.7 - 如何执行需要前一个子查询结果的多个子查询?
- reactjs - 创建反应应用程序时如何解决套接字超时
- javascript - 我的 laravel vue js 项目中的所有 Put & Delete 路由方法抛出 302 错误
- wiql - Azure DevOps 查询 - 返回特定用户在某个时间范围内编辑的工作项
- bodypix - 将 bodypix js 模型转换为 pb 。然后将 pb 转换为 tflite
- android - 在 Android 11 中创建 CSV 文件返回错误“java.io.FileNotFoundException: EPERM (Operation not allowed)”
- java - 运行 neo4j 时遇到错误:无法在 'dedicatedworkerglobalscope' 上执行 'postmessage' 数据无法克隆出内存
- android - 尝试对本地 Web api(离子 android 应用程序)的 http 请求时连接被拒绝