0

I have to compare 2 python strings, each of which is a multiline string (these are read from a file).

My code is this

list1 = [string1]
list2 = [string2]
differ = difflib.HtmlDiff()
htmlOut = differ.make_file(list1, list2)

When I copy htmlOut to an HTML file and open it in Chrome, multiline strings became a single line string.

I've also tried directly printing htmlOut to a file and then open that file. Even this approach doesn't work. What should I do here?

1 Answer 1

1

Replace python \n with <br> for HTML

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.