We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b2df706 commit 2ad0afeCopy full SHA for 2ad0afe
cookbook/c05/p02_print_tofile.py
@@ -7,7 +7,7 @@
7
8
9
def print_tofile():
10
- with open('somefile.txt', 'rt') as f:
+ with open('d:/work/test.txt', 'wt') as f:
11
print('Hello World!', file=f)
12
13
if __name__ == '__main__':
source/c05/p02_printing_to_file.rst
@@ -16,12 +16,12 @@
16
17
.. code-block:: python
18
19
20
21
22
----------
23
讨论
24
25
关于输出重定向到文件中就这些了。但是有一点要注意的就是文件必须是以文本模式打开。
26
-如果文件时二进制模式的话,打印就会出错。
+如果文件是二进制模式的话,打印就会出错。
27
0 commit comments