中国大学MOOC: 分析和运行下面程序,写出运行结果( )。f=open(sx7-1.txt,w)f.write(北京)f.write(上海)f.write(西安)f.write( 北京 )f.write(上海 西安 )f.close()
中国大学MOOC: 分析和运行下面程序,写出运行结果( )。f=open(sx7-1.txt,w)f.write(北京)f.write(上海)f.write(西安)f.write( 北京 )f.write(上海 西安 )f.close()
下列代码中能够正确实现追加写入的是( )。 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!')
下列代码中能够正确实现追加写入的是( )。 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("test.txt","wt") f.write("abc") f.seek(2,0) f.write("123") f.close() 程序时错误的,因为seek只能用在二进制文件操作中
f=open("test.txt","wt") f.write("abc") f.seek(2,0) f.write("123") f.close() 程序时错误的,因为seek只能用在二进制文件操作中
执行下列语句如果会报错,错误在第几行? f=open("w.txt","w+") f.write("Lux et Veritas") f.seek(4,1)
执行下列语句如果会报错,错误在第几行? f=open("w.txt","w+") f.write("Lux et Veritas") f.seek(4,1)
执行语句f=open("f.txt","w")后,不可以执行的语句是() A: f.write("123") B: f.close() C: f.read() D: f.flush()
执行语句f=open("f.txt","w")后,不可以执行的语句是() A: f.write("123") B: f.close() C: f.read() D: f.flush()
若文件data.txt中有字符串“飞雪连天射白鹿”,则不能将"笑书神侠倚碧鸳"写入该字符串后面的语句是( ) A: f=open("data.txt",'a')f.write("笑书神侠倚碧鸳")f.close() B: f=open("data.txt",'w+')f.write("笑书神侠倚碧鸳")f.close() C: f=open("data.txt",'w+')f.writelines(["飞雪连天射白鹿","笑书神侠倚碧鸳"])f.close() D: f=open("data.txt",'w')f.write("飞雪连天射白鹿笑书神侠倚碧鸳")f.close()
若文件data.txt中有字符串“飞雪连天射白鹿”,则不能将"笑书神侠倚碧鸳"写入该字符串后面的语句是( ) A: f=open("data.txt",'a')f.write("笑书神侠倚碧鸳")f.close() B: f=open("data.txt",'w+')f.write("笑书神侠倚碧鸳")f.close() C: f=open("data.txt",'w+')f.writelines(["飞雪连天射白鹿","笑书神侠倚碧鸳"])f.close() D: f=open("data.txt",'w')f.write("飞雪连天射白鹿笑书神侠倚碧鸳")f.close()
Watch the video. Read the statements. Write T (true) or F (false).
Watch the video. Read the statements. Write T (true) or F (false).
下列程序的输出结果是()。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
下列程序的输出结果是()。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
Tell whether the following statements are true or false. Write T for true and F for false.
Tell whether the following statements are true or false. Write T for true and F for false.
The first letter of the first line must be “F” if you are to write an acrostic pome of SPRING. ( )
The first letter of the first line must be “F” if you are to write an acrostic pome of SPRING. ( )