read python coderegular expressions from external files

As for the reading something from a file – it’s easy. Assume you have the file ‘my_file.txt’ in the same folder where the script is saved:

f =  open('my_file.txt', 'r')

content =              # read all content of the file in the sting 'content'
lines   = # read lines of the file in array 'lines'


print(lines[0]) # first line
print(lines[1]) # second line
# etc

As for shouldn’t bk.writefile be indented? Yep, it seems the loop makes and changes the variable html for several times but saves only the last iteration. It looks weird. Perhaps it should be indented. But it’s just a guess.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top