{:10_266:}
import urllib.request
with open('D:\\Python_Project\\2019.9.24\\urls.txt','r',encoding='utf-8') as f:
website_list = f.readlines()
length = len(website_list)
#print(website_list)
#print(length)
for i in range(1,length+1):
F = open('D:\\Python_Project\\2019.9.24\\url_%d.txt' %i,'w',encoding='utf-8')
response = urllib.request.urlopen(website_list)
html = response.read()
html = html.decode('utf-8')
F.write(html)
F.close()
thank you for sharing
努力學習中~
f.truncate()
——f.truncate(f.tell())
感谢老师的资料,让我,有种恍然大明白的感觉
1
支持一波。
坚决支持!!!!!!!!!!!!
看答案
课后题:
测试题:
0.B 应该和转义字符有关;
>>> f = open('E:\\Python\\小甲鱼\\2/test0.txt')
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
f = open('E:\\Python\\小甲鱼\\2/test0.txt')
FileNotFoundError: No such file or directory: 'E:\\Python\\小甲鱼\\2/test0.txt'
>>> f = open('E:\\Python\\小甲鱼\\2/test0.txt','w')
>>> f = open('E:\\Python\\小甲鱼\\2\test1.txt','w')
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
f = open('E:\\Python\\小甲鱼\\2\test1.txt','w')
OSError: Invalid argument: 'E:\\Python\\小甲鱼\\2\test1.txt'
>>> f = open('E:\\Python\\小甲鱼\\2//test2.txt','w')
1.可读
2.二进制,可执行
3.这个不太清楚
4.
5.
>>> for each in f:
print(each)
尔康:肿么了,我们昨天不是已经把话说明白了吗?又出什么事了?脸色怎么这么苍白?为什么不看着哥?
紫薇:你骗我?
尔康:我又怎么了?
紫薇:紫薇。你跟我说你和紫薇没有过去,可是在回廊下看雪看月亮谈了整整一晚,难道这不算是过去吗?你可以爱柳青柳红,可以爱小燕子,可以爱紫薇,可以爱五阿哥,就不可以爱我吗?
6.
>>> f.read(10)
'尔康:肿么了,我们昨'
7。tell()
8.我测试完没出错啊。
>>> f.seek(45,0)
45
where is the record.txt file(the lesson 29)?
为什么Mac打不开桌面文件老是提醒错误
kankankankan
做完作业再看更有收获。
感谢小甲鱼!!!
seek里,现在用法已变,from是默认了
学习
打卡
{:10_249:}{:10_269:}{:10_269:}