Is importing os module necessary to os.listdir()

  python

Do you import os to do os.listdir()
I don’t know why, but when I do

for file in os.listdir():
        print(file)

There aren’t any errors, even more when I import os, pycharm offers me to delete it.
Is it OK?

Source: Python Questions

LEAVE A COMMENT