下列程序的输出结果是()。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
A: Pyth
B: Python
C: Py
D: th
举一反三
- f=open('c: \ \out.txt’, 'w+')f.write('Python')f.seek(0)c=f.read (2)print(c)f.close(),以上程序的输出结果是( ) A: Python B: th C: Py D: Pyth
- 下列程序的输出结果是( )。 import os f = open(r'D:\test.txt','w+') f.write('Python') f.seek(0) m = f.read(3) print(m) f.close() A: Pyt B: Python C: yth D: Py
- 下列程序的输出结果是()。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
- import randomf = open(‘data.txt’,‘w+’)for i in range(100000):f.write(str(random.randint(1,100)) + ‘\n’)f.seek(0)print(f.read())f.close()问:创建的data.txt文件中有多少行
- 下列代码中能够正确实现追加写入的是( )。 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!')