mirror of
https://github.com/rasbt/python_reference.git
synced 2025-02-21 07:42:09 +00:00
Update file_browsing.py
This commit is contained in:
parent
0750d4f75d
commit
87dcbfe7f3
|
@ -4,6 +4,7 @@
|
|||
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
# working directory
|
||||
c_dir = os.getcwd() # show current working directory
|
||||
|
@ -11,6 +12,12 @@ os.listdir(c_dir) # shows all files in the working directory
|
|||
os.chdir('~/Data') # change working directory
|
||||
|
||||
|
||||
# get all files in a directory
|
||||
>>> glob.glob('/Users/sebastian/Desktop/*')
|
||||
|
||||
# e.g., ['/Users/sebastian/Desktop/untitled folder', '/Users/sebastian/Desktop/Untitled.txt']
|
||||
|
||||
|
||||
|
||||
# walk
|
||||
tree = os.walk(c_dir)
|
||||
|
|
Loading…
Reference in New Issue
Block a user