Japan's simplest Python memo (dialog box, etc.)

Note that I learned to operate files with python.

■ Display the files in the selected folder in a row using the dialog box, os.walk function, and pprint.


    #Import required modules
    import sys
    import os
    import tkinter,tkinter.filedialog
    #Import to display files in a row
    import pprint

    #Creating a file dialog
    root.withdraw()#Description because processing may stop when the main window of Tkinter starts
    msg='Please select a folder'
    if (not my_path):
    print('User canceled')

    #OS.Use the walk function to scan and display the files in the folder
    for dirpaht,dirs,files in os.walk(my_path):
    for fname in files:

When executed, the file dialog is displayed, so select the folder.


The execution result is displayed. The results are displayed in a row by using pprint.


Recommended Posts

Japan's simplest Python memo (dialog box, etc.)
Python memo
python memo
Python memo
python memo
Python memo
Python memo
Python memo
Statistical basics and Python, graphing, etc. (memo)
[Python] Memo dictionary
python beginner memo (9.1)
★ Memo ★ Python Iroha
[Python] EDA memo
Python 3 operator memo
[My memo] python
Python3 metaclass memo
[Python] Basemap memo
Python beginner memo (2)
[Python] Numpy memo
Memo to create your own Box with Pepper's Python
The simplest Python memo in Japan (classes and objects)
Python class (Python learning memo ⑦)
My python environment memo
python openCV installation (memo)
Python module (Python learning memo ④)
Visualization memo by Python
Convenient Python methods, etc.
Python test package memo
python regular expression memo
Binary search (python2.7) memo
[My memo] python -v / python -V
Python3 List / dictionary memo
Python Tips (my memo)
[Python] Memo about errors
DynamoDB Script Memo (Python)
Python basic memo --Part 2
python recipe book Memo
Basic Python command memo
Python OpenCV tutorial memo
Python basic grammar memo
TensorFlow API memo (Python)
python useful memo links
Python decorator operation memo
Python basic memo --Part 1
Effective Python Memo Item 3
Divisor enumeration Python memo
Select file in dialog with python → Display file name in message box