New to python and getting errors in this very simple script:
from os import listdir all_files = os.listdir("/root/raw/") for file in all_files: print file
What am I doing wrong here? It looks correct in accordance with the documents.
You imported listdirfrom os, so os.listdirit means nothing, while it listdirmeans something
listdir
os
os.listdir
Call
all_files = listdir("/root/raw/")
Or change the import to
import os
You only imported the function listdirthat is in your current namespace. This way you can directly access it, for example,
If you did this,
os listdir, os.listdir