I am working on a project to improve my python skills on file saving when this happened:
(I am writing an example):
appND = """inp = input("Type enter to run")
open('file.py', 'x').write('print("Hi,\n\n I am confused")')"""
When I ran the program it saved this to the file:
print("Hi,
I am confused")
This would not be a problem but I want to publish a 300 lines long file with a recovery script to recover the original file which saves specific numbers to a .txt file, but every time I run the recovery .py file, There are EOL errors.
I hope that an advanced programmer helps me with this...
you can add another backslash () before to make it work
d = "i love '\\n' python."
print(d)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.