1

print 输出直接到文件里
主要是python版本问题,语法不一样,这里记录一下。

python 3.x

#!/usr/bin/env python3  
#coding:utf-8
K = 10
f = open("./output/recard", 'w+')  
for i in range(K) 
    print("第{0}条数据".format(i), file=f)  

python 2.x

#!/usr/bin/env python3  
#coding:utf-8
K = 10
f = open("./output/recard", 'w+')  
for i in range(K) 
    print>>f,"第{0}条数据".format(i)  

jasperyang
203 声望58 粉丝

Highest purpose is Hacking...