my_list = [i**2 for i in range(1,11)]
my_file = open("output.txt", "r+")
# Add your code below!
for num in my_list:
my_file.write(str(num)+"\n")
my_file.close()
# text.txt
I'm the first line of the file!
I'm the second line.
Third line here, boss.
# code
my_file = open("text.txt" , "r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()
第五节
1 介绍了with...as...结构的使用
2with open("file","mode") as variable: