Human: In Python, is it possible to escape newline characters when printing a string? Assistant: 
Here is some code to print new line character as `\n` in a string `foo\nbar`

print('foo\nbar'.encode('string_escape'))

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.