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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -