2021-01-10 14:50:10 (edited by mohamed 2021-01-10 14:53:16)

hi, So am having a odd problem, Whenever i write something thru the open.write, Where there's something that looks like hi, And then a new line, And then my name is something, When i write it thru data=open("filename","w") and then i do data.write(stuffToAdd) when i look into the file, Between the hi and my name is something, The program inserted a extra blank line, And if i take the edited file and write again, The thing doubles it from 1 extra line between lines to 2, And if i do again doubles to 4, And so on, Is there a fix to this?
edit, So an example, Lets say i have this text.
hello there
this is a text
and this a text too.
ok, So after writing.
hello there

this is a text

and this is a text too.

2021-01-10 16:05:05

hmm, what? it looks like both are same

if you like this post, please thum it up!
if you like to see my projects, feel free to check out my github
if you want to contact me, you can do here by skype. or you can follow me on twitter: @bhanuponguru
discord: bhanu#7882

2021-01-10 16:16:53

I don't get what you're trying to say. They are the same to me. Did you come up with something like this:

with open("test.txt", mode="w") as f:
    f.write("Hi, how are you \r\n")
    for x in range(1, 11):
        f.write(str(x ** 2) + "\r\n")
Facts with Tom MacDonald, Adam Calhoun, and Dax
End racism
End division
Become united

2021-01-10 20:22:14

My money is on the text editor is displaying \r as a newline, they're writing \n themselves, and it's getting converted to \r\n by Python.  Try this:

open("myfile.txt", "wb")

And see if it does what you want.

My Blog
Twitter: @ajhicks1992