Search code examples
pythonvariablespexpect

Python pexpect - python 2.6 - unable to print variable and > in one line


I am trying to concatenate string + variable + string picks up the variable from the file using Python

with open("file.txt") as fh:
for line line in fh:
d = "c:/" + xyz + ">"
print d

it prints c:/xyz > I wanted the output as "c:/xyz>". When i am trying in interactive mode it prints it fine.


Solution

  • It's hard to understand the question because of the weird formatting, but in any case try using the format method:

     d = "c:/{}>".format(xyz.strip('\n'))