0

I need to write one line of formatted text to a *.rtf file with Python. If I tried to print this line, here is how I would do it in Python:

print Kelvin of %s sensor at C is %s K, recorded with command p -V2 bery.org. % (MAC,210)

However, I need to write this single line to a file using formatted output placeholder %s.

When writing this line to a file:

  1. I need the word MAC to be printed in the Consolas font.
  2. I need all other text on the line to be printed in Arial font.

Is this possible with Python (on Windows)?

edesz
  • 11,756
  • 22
  • 75
  • 123
  • Did you google it? First result: http://www.pindari.com/rtf1.html – Aske Doerge Dec 06 '15 at 01:12
  • Thanks but it doesn;t seem to be printing with a placeholder `%s` which I am having trouble with. If the whole line is one font, then I can do it. I just need a few words to be of different font BUT I need those same words to be printed using variables. – edesz Dec 06 '15 at 01:22
  • 2
    Perhaps this will help then: http://stackoverflow.com/questions/14401902/setting-font-style-for-rtf-document Set the default font to Arial and create a font which you then use around the correct %s in your example. – Aske Doerge Dec 06 '15 at 01:34
  • Yup got it! Thanks. That works. This Question has been answered. – edesz Dec 06 '15 at 01:50

0 Answers0