dimanche 4 mars 2018

Can you read the spaces or tabs in the beginning of a line in a file?

So I've been trying to see if I can find the tabs or the spaces of a file. I used this for now and I can't figure it out how am I supposed to call the space or tab or how to find it.

file = open("file.txt","r")
    for space in line:
        if line.find("    "):
            print("This is something I want to add to the line",line)
#line in print is the rest of that line that has a tab or spaces in front of the text.

File Data:

Names: / Status: 

John
      unavailable 
          unavailable

Mike
      available

Jack
      available

The tabs from the Status column I need to find a way to read them. One line may have multiple tabs.

Aucun commentaire:

Enregistrer un commentaire