Closed vezycash closed 7 years ago
https://github.com/thewhitetulip/build-app-with-python-antitextbook/blob/master/01-intro-to-python.md#example-list-all-txt-files
import os files = os.listdir() for file in files: if file.endswith(".txt"): print(file)
Function os.listdir() expects an argument (a folder name)
files = os.listdir("folder")
folder = the folder which contains the text files.
OR files=os.listdir(".") //In this case, the files have to be in the same directly as file.py
Actually, since pytjon3 it accepts zero arguments, if there is no argument, it lists the current directory
You're right.
https://github.com/thewhitetulip/build-app-with-python-antitextbook/blob/master/01-intro-to-python.md#example-list-all-txt-files
Function os.listdir() expects an argument (a folder name)
files = os.listdir("folder")
OR files=os.listdir(".") //In this case, the files have to be in the same directly as file.py