Forum Archive

How to create folder in Pythonista

yash

Plz help me out how to make folder in pythonista and use open function to read and write

Bumbo Cactoni

@yash
I’m not 100% sure what you mean by how to create a folder, but here’s how to use the open() function, which includes a file-creating thingy:

Replace the “mode” with one of these modes, as needed; also, the mode must be in quotation marks, or else it returns an error:

t — open in text (default)
b — open in binary

r — read (default)
w — write - for editing a file - will create a file if one does not exist with the given name
r+ — read and write - for updating a file
x — exclusively creates a file - fails if the file exists

Assign a variable to opening the file:

file = open(“file.extension”, “mode“)

where you change “mode” to one of the above modes

Let me know if you need some extra help understanding it!

ccc

A Google search on make a directory in Python returns 113 million (literary) hits in < 1 second. Please try a few of those.