سؤال

Why am I getting output on my console when writing to file? I don't recall this ever happening before...

outfile= open("C:\\Data\\testout.txt", 'w')
outfile.write("something")
outfile.write("something else")

output:

9
14
هل كانت مفيدة؟

المحلول

In Python versions > 3.0, the write method returns the number of bytes written.

http://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top