1월, 2020의 게시물 표시

Python - File, directory manipulation

First you should import os modules. import os Get current working folder import os dir = os . getcwd() print(dir) Change current working directory import os dir = os . getcwd() print(dir) os . chdir( "/home" ) dir = os . getcwd() print(dir) Get absolute path for specific path import os dir = os . getcwd() print(dir) os . chdir( "/home" ) dir = os . getcwd() print(dir) os . chdir( "pi" ) abs_dir = os . path . abspath( './rpi-rgb-led-matrix' ) print(abs_dir) # '/home/pi/rpi-rgb-led-matrix' Get only directory name in path import os dir = os . getcwd() print(dir) os . chdir( "/home" ) dir = os . getcwd() print(dir) os . chdir( "pi" ) abs_path = os . path . abspath( './rpi-rgb-led-matrix' ) print(abs_path) dir_name = os . path . dirname( '/home/pi/rpi-rgb-led-matrix/README.md' ) print(dir_name) # '/home/pi/r...

Python Jupyter Notebook with VSCode

이미지
If you are a Python developer, I highly recommend watching this video from Microsoft VS Code Team . Many Python developers use Jupyter notebooks during development. Jupyter notebooks are usually easy to debug because they can be executed block by block in a web browser. Microsoft has finally improved the Python extension to enable running Jupyter Notebooks in VSCode. VS Code's Python extension allows you to save files created with Jupyter Notebook (ipynb) as files with the py extension. And the saved py extension file is compatible with Jupyter Notebook in Vs Code. This feature is amazing. If you watch this video, you will have no choice but to turn your Python development tools into VSCode. Install Python extension  First in the VSCode, install python extension from Microsoft. Then open or make a new python file. You can see that the Python source code is syntax highlighted. And at the bottom of VSCode you can see your current Python. If you are using multiple Py...