Home > Software design >  Save changes in a python script using command
Save changes in a python script using command

Time:02-20

I open my Python scripts on JupyterLab and make some changes if required. And I need to save changes using written command in my script. Something that will immitate CTRL S command and do update my local file with all the changes.

Does anybody know how to handle this situation?

CodePudding user response:

There are some python modules to handle this situation for you(like keyboard and PyAutoGUI ). but they are not built-in python and first of all you have to install them using pip install command(you have to have admin privilege to install them). but if you want to save your python script using a command in Jupyter, you can use the following command in a jupyter cell and press Enter:

%%javascript
IPython.notebook.save_notebook()

It will automatically save your changes.

I wish it could help you.

CodePudding user response:

You can use keyboard module.

import keyboard # Do pip install keyboard if it shows ModuleNotFoundError
#Your code
keyboard.press_and_release('ctrl   s') #Saves the code
  • Related