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 = f.read() # read all content of the file in the sting 'content'
lines = f.read().splitlines() # read lines of the file in array 'lines'
f.close()
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.