1

I'm writing a python script to create an fdf file. The first 2 lines of fdf file require the following:

%FDF-1.2
%‚„œ”

How can I write the symbols required in those two lines as a string? When I create a new line, (e.g. line_1 = "%FDF-1.2") I get an error because of the % symbol. I need python to read it as text and not a command symbol.

CraigTeegarden
  • 8,173
  • 8
  • 38
  • 43
Travis May
  • 25
  • 4

2 Answers2

1

A '%' must be escaped as '%%'. Otherweise it acts as placeholder for string interpolation.

Related:

Community
  • 1
  • 1
1

Use a the raw string notation

>>> a = r'%test'
>>> print a
%test
rxdazn
  • 1,380
  • 1
  • 14
  • 30