Text files involving Python

--Originally published at Nihilistic Kirby

Did you ever wanted to know if any other forms of files interact with you python code?

Have you ever wanted to use a text file as some kind of dictionary?

Well, don’t worry any longer, because I’ve got the answer you’re looking for. First of all, python codes works with really simple commands, making this one of the most easiest but practical languages to work with. So you might be surprised if I tell you that the simple command of “>>>open()” including the name of the archive between apostrophes.

This will make every line of text a list that you can manipulate with ranges. There’s an example for it in which I opened a text file full of values as number:

cartxt = open(“93cars.dat.txt”)
for line in cartxt:
a = line[52:54]
b = line[55:57]
c = line[42:46]