How do i watch python source code files and restart when i save?

后端 未结 5 809
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 12:27

When I save a python source code file, I want to re-run the script. Is there a command that works like this (sort of like nodemon for node)?

5条回答
  •  无人及你
    2020-12-28 13:21

    You actually can use nodemon with python, from their docs:

    Running non-node scripts nodemon can also be used to execute and monitor other programs. nodemon will read the file extension of the script being run and monitor that extension instead of .js if there's no nodemon.json:

    nodemon --exec "python -v" ./app.py

    Now nodemon will run app.py with python in verbose mode (note that if you're not passing args to the exec program, you don't need the quotes), and look for new or modified files with the .py extension.

    https://github.com/remy/nodemon#running-non-node-scripts

提交回复
热议问题