Python sample use subprocess to call command line tool dwdiff to diff by words.
https://os.ghalkes.nl/dwdiff.html
https://stackoverflow.com/questions/1996518/retrieving-the-output-of-subprocess-call
https://github.com/beepscore/diffie
On Linux, can use apt-get or similar
On macOS, can use homebrew.
I don't know if dwdiff is available for Windows.