python - How can I check that a text file has at least 1 character -


i have text file how can check in python text file has @ least 1 number or alphabetic character , not white spaces.

here did. read file putting data string data. used data.strip() remove leading , trailing whitespace. checked see if there left data.strip(). if there have characters in file, if not file has whitespace or empty.

with open("filename.txt", "r") file:     data = file.read()  if data.strip():     print("empty") else:     print("full") 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -