Question

Write a program in python that takes a txt file and converts it to html

Write a program in python that takes a txt file and converts it to html

Homework Answers

Answer #1

Write a program in python that takes a txt file and converts it to html

Just change your code to include <pre> and </pre> tags to ensure that your text stays formatted the way you have formatted it in your original text file.

contents = open"C:\\Users\\Suleiman JK\\Desktop\\Static_hash\\test","r")
with open("suleiman.html", "w") as e:
    for lines in contents.readlines():
        e.write("<pre>" + lines + "</pre> <br>\n")

In the contents variaable you should give uour own path for the changing of file from txt to html.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write an awk (nawk) or sed command file that converts a textfile to a html file...
Write an awk (nawk) or sed command file that converts a textfile to a html file (by inserting tags <HTML><BODY><PRE> at the beginning of your existing file: file1.txt and inserting tags </PRE> ></BODY></HTML> at the end of file1.txt) Sample Run: awk -f awkfile.txt file1.txt > file1.html or use sed –f sedfile.txt file1.txt > file1.html Sample Output: Use a browser to show your file1.html
python program 1. create a .txt file and call it fruits.txt, add the following items to...
python program 1. create a .txt file and call it fruits.txt, add the following items to the file Apple Banana Peach Strawberry Watermelon Kiwi Grape 2. Write a program that does the following: - Reads the fruit.txt - Converts the contents into all uppercase - Writes the uppercased values into a text file called "UpperFruit.txt" OUTPUT SHOULD BE: APPLE BANANA PEACH STRAWBERRY WATERMELON KIWI GRAPE
THE CODE MUST BE PYTHON # create a file with the name <last_three_digits_of_your_empl_id>.txt # write into...
THE CODE MUST BE PYTHON # create a file with the name <last_three_digits_of_your_empl_id>.txt # write into this file two lines: # 1. your name # 2. your hobby # close this files. # # open the created files <last_three_digits_of_your_empl_id>.txt, # add a third line to this file with today's date. # close the file.
#python program Read and Write to PDF Read txt, docx Create converter for taking the imported...
#python program Read and Write to PDF Read txt, docx Create converter for taking the imported documents and converting to .txt for parsing Create converter from .txt of python summary output to PDF Create converter from .txt of python summary output to .doc Add this functionality through a gui
Write a Python program using that takes a number as input and then prints if the...
Write a Python program using that takes a number as input and then prints if the number is even or odd. The program should use a function isEven that takes a number as a parameter and returns a logical value true if the number is even, false otherwise.
a program that takes a binary file and opens it and translates the data and prints...
a program that takes a binary file and opens it and translates the data and prints to a new text file. written in python
Write a python program that prompts the user for a web address (full url, html page)...
Write a python program that prompts the user for a web address (full url, html page) and then uses the BeautifulSoup and urllib to read its data. You can use the any html page you'd like: The program should output the following: The page title (hint: read the content from the metatag "title") The total number of words on the page The total number of unique words on the page The total number of each heading used on the page...
Please do this in C: Write a program that takes the name of the file that...
Please do this in C: Write a program that takes the name of the file that you created as input, find the maximum and minimum among all the numbers in the file, and output them.
Write Java program Lab51.java which takes in a string from the user, converts it to an...
Write Java program Lab51.java which takes in a string from the user, converts it to an array of characters (char[] word) and calls the method: public static int countVowels(char[]) which returns the number of vowels in word. (You have to write countVowels(char[]) ).
(PYTHON) Q8 Write a program: Have the program takes three arguments (two floats) and returns if...
(PYTHON) Q8 Write a program: Have the program takes three arguments (two floats) and returns if the numbers are even or odd. Desired output: 12.0 Even
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT