0

Can I replace a "enter key" for a " " in Python? Read description

I am trying to translate PDFs using Google traductor but when I tried to paste it on Google traductor I have to errase manually the spaces Auto generated on pdf files (that I call in the question "enter key") . And this makes problems in the translation. Here is an example: Modify this: "Recently, and with increasing frequency, an idea has begun to turn in our minds and to beat in our hearts: the ambition of being the creators of our own thinking. " To this: "Recently, and with increasing frequency, an idea has begun to turn in our minds and to beat in our hearts: the ambition of being the creators of our own thinking" I tried to make this on Python because I'm learning and I am in big problems. Can someone help me? This is my code: file = open("newfile.txt", "w") file.write("""Recently, and with increasing frequency, an idea has begun to turn in our minds and to beat in our hearts: the ambition of being the creators of our own thinking. """) file.close() file = file.replace("/n"," ") file = open("newfile.txt", "r") print(file.read()) file.close() I am a beginner in Python. Sory for the terrible code

26th Apr 2020, 4:05 PM
Maco
Maco - avatar
6 ответов
+ 7
You can replace " " with "/n" . Post your code for more details.
26th Apr 2020, 4:22 PM
Valmob101
Valmob101 - avatar
+ 1
copy paste in a plain-text editor, save the file, and open/read the file with Python ^^ (you could keep interaction with user by prompting for filename/path to load ;))
26th Apr 2020, 4:16 PM
visph
visph - avatar
0
show your try first....
26th Apr 2020, 4:16 PM
Alexander Thiem
Alexander Thiem - avatar
0
file = open("newfile.txt", "w") file.write("""Recently, and with increasing frequency, an idea has begun to turn in our minds and to beat in our hearts: the ambition of being the creators of our own thinking. """) file.close() file = file.replace("/n"," ") file = open("newfile.txt", "r") print(file.read()) file.close() I am a beginner in Python. Sory for the terrible code
26th Apr 2020, 4:48 PM
Maco
Maco - avatar
0
try this:-..... file = open("newfile.txt", "r") mystring = file.read().replace('\n', '') file.close() print(mystring)
26th Apr 2020, 5:51 PM
rodwynnejones
rodwynnejones - avatar
0
Oh, thank you very much!!!!! Graciasss
26th Apr 2020, 6:15 PM
Maco
Maco - avatar