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
Python Write function stringCount() that takes two string inputs—a file name and a target string— and...
Python Write function stringCount() that takes two string inputs—a file name and a target string— and returns the number of occurrences of the target string in the file. >>> stringCount('example.txt', 'line') 4
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[]) ).
The following code to run as the described program on python. The extra test file isn't...
The following code to run as the described program on python. The extra test file isn't included here, assume it is a text file named "TXT" with a series of numbers for this purpose. In this lab you will need to take a test file Your program must include: Write a python program to open the test file provided. You will read in the numbers contained in the file and provide a total for the numbers as well as the...
I need python code for this. Write a program that inputs a text file. The program...
I need python code for this. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase words should take precedence over lowercase words. For example, 'Z' comes before 'a'. The input file can contain one or more sentences, or be a multiline list of words. An example input file is shown below: example.txt the quick brown fox jumps over the lazy dog An example of the program's output...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT