执行下列语句如果会报错,错误在第几行? f=open("w.txt","w+") f.write("Lux et Veritas") f.seek(4,1)
举一反三
- 下列程序的输出结果是()。f=open("w.txt","w+")f.write("LuxetVeritas")f.seek(7)s=f.read(3)f.close()print(s) A: tas B: Lux C: eri D: Ver
- 执行语句f=open("f.txt","w")后,不可以执行的语句是() A: f.write("123") B: f.close() C: f.read() D: f.flush()
- f=open("test.txt","wt") f.write("abc") f.seek(2,0) f.write("123") f.close() 程序时错误的,因为seek只能用在二进制文件操作中
- 下列代码中能够正确实现追加写入的是( )。 A: with open("d:\\python\\data.txt",'w') as f: f.write('Hello!') B: with open("d:\\python\\data.txt",'a') as f: f.write('Hello!') C: with open("d:\\python\\data.txt",'r+') as f: f.write('Hello!') D: with open("d:\\python\\data.txt",'wb+') as f: f.write('Hello!')
- 下列程序的输出结果是()。f=open('out.txt','w+')f.write('Python') f.seek(0)c=f.read(2) print() f.close() A: Pyth B: Python C: Py D: th