The file outside of Python

If you now exit the REPL, and look in your filesystem you can see that you have indeed created a file. On Unix use the ls command:

$ ls -l
-rw-r--r-- 1 rjs staff 78 12 Jul 11:21 wasteland.txt

You should see the wasteland.txt file with 78 bytes.

On Windows use dir:

> dir
Volume is drive C has no label.
Volume Serial Number is 36C2-FF83

Directory of c:Userspyfund

12/07/2013 20:54 79 wasteland.txt
1 File(s) 79 bytes
0 Dir(s) 190,353,698,816 bytes free

In this case you should see wasteland.txt with 79 bytes because Python's universal newline behavior for files has translated the line ending to your platform's native endings.

The number returned by the write() method is the number of codepoints (or characters) in the string passed to write(), not the number of bytes written to the file after encoding and universal newline translation. In general, when working with text files, you cannot sum the quantities returned by write() to determine the length of the file in bytes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset