Home > database >  How to open a .html file
How to open a .html file

Time:08-22

for a little project i'm trying to create a python program which allows me to run it and then go to open files in html format that I created earlier. But i need that the files are opened in the "browser" and not in the visual code terminal.

this is my code:

import os 
RdFile = open(link.html, 'r')
RdFile = RdFile.readline()
for row in Rdfile:
    print(row),
input()

and that open in the shell the file so I was wondering how to make the python file run to open the file directly in its format and not from the terminal.

Thanks

CodePudding user response:

You are making your code print the lines that are inside the file.

This should work:

import webbrowser

RdFile = webbrowser.open(r'path')  #Full path to your file
  • Related