Now you can find the list_file.py has been created or overwrote in your jupyter notebook webserver started folder.Select the above line cell to make it focus, then click the Run button at the top to run it, then you can see a message is printed, the message is Writing list_file.py ( if list_file.py do not exist ) or Overwriting list_file.py ( if list_file.py exist ).# print out file name in the standard output. # get all the dir_name directory contained files in a list # give the first argument value to a local variable, the argument value should be a directory name. # set dir_name value to current directory by default. # use ipython magic command %%writefile to create a python script file and write below script content to it. If you do not pass any folder name as the command line input arguments when you invoke list_file.py, it will list the files and directories’ names in the current directory. When you run this python script file in jupyter notebook, it will print out all the files and directories’ names in the folder which you pass to it as a command-line input argument. Below ipython code will create a python script file with name list_file.py. Add the first line cell and input below source code. Click file InvokePythonScript.ipynb to edit it.( There are also 2 python script files list_file.py and list_file_path.py which we will introduce later. Create a jupyter notebook file with the name InvokePythonScript.ipynb.Invoke Python Script File From Jupyter Notebook.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |