FlashKeepers

Python · Python · College and University

Python Standard Library Essentials

Commonly used standard library modules including os, sys, datetime, and json, each explained with a short example.

About this set

35 basic cards for Python Python. It opens with "What does os.getcwd() do?" and "What does os.listdir(path) return?". More College and University decks are listed below.

35 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What does os.getcwd() do?
Show answerReturns the current working directory as a string.
What does os.listdir(path) return?
Show answerA list of filenames and directory names in the given path.
What does os.path.join('dir', 'file.txt') do?
Show answerConcatenates path components using the OS-specific separator.
What does os.makedirs('a/b/c') do?
Show answerCreates nested directories, including parent directories if needed.
What is sys.argv in Python?
Show answerA list containing command-line arguments passed to the script.
What does sys.exit(1) do?
Show answerTerminates the program and returns the exit code 1 to the system.
What does sys.version return?
Show answerA string describing the Python version and build information.
What does datetime.datetime.now() return?
Show answerA datetime object representing the current date and time.
What is datetime.timedelta used for?
Show answerRepresents a duration, the difference between two dates or times.
What does strftime('%Y-%m-%d') do?
Show answerFormats a datetime object as a string using the given format code.
What does json.dumps(dict) do?
Show answerConverts a Python dictionary to a JSON-formatted string.
What does json.loads(string) do?
Show answerParses a JSON string and returns a Python dictionary or list.
What does json.dump(data, file) do?
Show answerWrites a Python object as JSON directly to a file.
What does collections.Counter() do?
Show answerCounts hashable objects and stores the counts in a dictionary-like object.
What does collections.defaultdict(int) do?
Show answerCreates a dictionary that returns a default value (int, 0) for missing keys instead of raising KeyError.

20 more cards in the app

Study this set free