I am writing a program to analyse weblogs. I put the various results into a variable called "output" and write the output at the end to a text file. Below is just one example:
output += "\nFiles and how many times they have been accessed: \n"
for key in accessedFiles.keys():
output += key + "-> time(s) accessed is: " + "\t" + str(accessedFiles[key]) + " \n"
The output looks like this:
/paperarticles/Nov02-Bushswar.htm-> time(s) accessed is: 1
/Documents/NinaSimone.htm-> time(s) accessed is: 1
/cwi.css-> time(s) accessed is: 1
There are similar questions that refer to the print command. I figured out how this would work with f-string
but I am not using print in my code. Also, "\t"
does not work because there are different legnt of strings. Any idea of how I could align like this? Below is handmade just for visualisation purpose:
/paperarticles/Nov02-Bushswar.htm time(s) accessed: 1
/Documents/NinaSimone.htm time(s) accessed: 1
/cwi.css-> time(s) accessed: 1
This is my first question to the forum. I hope I did everything right. Thank you so much for your help. Chris