题目内容

以下程序的输出结果是:()fo = open("text.txt",'w+')x,y ='this is a test','hello'fo.write('{}+{}\n'.format(x,y))print(fo.read())fo.close()

A. this is a test hello
B. this is a test+hello
C. this is a test
D. this is a test,hello.

查看答案
更多问题

下列操作能够创建文件对象的是()

A. make()
B. create()
C. open()
D. file()

关于语句f = open("a.txt", "w+"),下列说法正确的是()

A. 只能写入数据
B. 只能读取数据
C. 文件可以不存在
D. 文件必须已经存在

下方程序的功能是:提示用户输入姓名,每次用户输入姓名后,会在屏幕上打印一句问候语,并将这条问候记录添加到文件guest_book.txt中,每条记录独占一行。name=input('请输入你的姓名:')book=name+',你好!欢迎光临!'print(book)My_file=open('guest_book.txt','a')_______________My_file.close()请问哪个选项填入上方下划线后,会导致程序出错( )。

A. My_file.write(book+'\n')
B. My_file.write([book+'\n'])
C. My_file.writelines(book+'\n')
D. My_file.writelines([book+'\n'])

二进制文件和文本文件都是可以用文本编辑器编辑的文件。

A. 对
B. 错

答案查题题库