testing content of each line in a text file in python -
testing content of each line in a text file in python -
i want write programme reads of lines given python text file , tests if line has letters and/or numbers , if not print error message
you can utilize file.readlines() iterates on lines in file. here's example.
with open("/path/to/my/file.txt") file_to_read: line in file_to_read.readlines(): # check if non-letter/number character in each line do note readlines() include \n @ end of each line, remember remove it. simple search on google "python read file line line" have given result.
python
Comments
Post a Comment