import pymongo import webbrowser client = pymongo.MongoClient("mongodb://localhost:27017/") mydb = client["school"] mycol = mydb["students"] stud = [] tbl = "NameAgeSection" stud.append(tbl) for y in mycol.find(): a = "%s"%y['name'] stud.append(a) b = "%s"%y['age'] stud.append(b) c = "%s"%y['section'] stud.append(c) contents = ''' Python Webbrowser %s
'''%(stud) filename = 'webbrowser.html' def main(contents, filename): output = open(filename,"w") output.write(contents) output.close() main(contents, filename) webbrowser.open(filename)