How to run a notebook using command line

I know the user can convert the notebook into a script and run python in the terminal.
Is there any way more convenient to do this task like python to run notebook.

Yes, you can directly run a notebook file from the command line. Two main ways I use are nbconvert and papermill. See the third paragraph here for links to documentation for each and some examples.

By the way since you mentioned .py files, jupytext can convert a script back to a notebook and run that notebook in one command, here. It also does the conversion from notebook to script on the command line, too.

Here’s an from example from the nbconvert 6.0 docs using the nbconvert api:

Thanks, I find the solution.

Executing notebooks from the command line
The same functionality of executing notebooks is exposed through a command line interface or a Python API interface. As an example, a notebook can be executed from the command line with:

jupyter nbconvert --to notebook --execute mynotebook.ipynb