-
-
Save rainly/874111 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
从一个文件里面按行读 | |
f = open(filename, 'r') | |
while 1: | |
line = f.readline() | |
if not line: | |
break | |
..... | |
读 pickle 文件 | |
import cPickle as pickle | |
f = open(filename, 'r') | |
data = pickle.load(f) | |
将标准输出指向文件 | |
def output(): | |
origin = sys.stdout | |
f = open('no_works.txt', 'w') | |
sys.stdout = f | |
main() | |
sys.stdout = origin | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment