修正5.2小节的bug~
This commit is contained in:
@@ -7,7 +7,7 @@ Desc :
|
|||||||
|
|
||||||
|
|
||||||
def print_tofile():
|
def print_tofile():
|
||||||
with open('somefile.txt', 'rt') as f:
|
with open('d:/work/test.txt', 'wt') as f:
|
||||||
print('Hello World!', file=f)
|
print('Hello World!', file=f)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
with open('somefile.txt', 'rt') as f:
|
with open('d:/work/test.txt', 'wt') as f:
|
||||||
print('Hello World!', file=f)
|
print('Hello World!', file=f)
|
||||||
|
|
||||||
----------
|
----------
|
||||||
讨论
|
讨论
|
||||||
----------
|
----------
|
||||||
关于输出重定向到文件中就这些了。但是有一点要注意的就是文件必须是以文本模式打开。
|
关于输出重定向到文件中就这些了。但是有一点要注意的就是文件必须是以文本模式打开。
|
||||||
如果文件时二进制模式的话,打印就会出错。
|
如果文件是二进制模式的话,打印就会出错。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user