Created
August 16, 2013 02:56
-
-
Save 1c7/6246893 to your computer and use it in GitHub Desktop.
(Python) 最短的写文件代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
out = open('a.txt', 'w') | |
print('Hello Earth!', file=out) | |
out.close() | |
# 在 Python3.3.0 能成功运行 | |
# 2.7不行 | |
# 这会创建一个叫做a.txt的文件, 内容是'Hello Earth!', 屏幕上并不会有任何输出 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这段代码是看Head First Python学来的
在实体书的p110
电子书的p153