单选题 适中
#17010

执行以下Python代码后,输出的结果是? ( ) with open ( 'test.txt' , 'w' ) as f : f . write ( 'Hel…

执行以下Python代码后,输出的结果是? ( )

with open('test.txt', 'w') as f:
    f.write('Hello')
with open('test.txt', 'a') as f:
    f.write('World')
with open('test.txt', 'r') as f:
    print(f.read())
未登录也能判分,登录后才会记录
答案与解析
正确答案:C
解析
'w'模式清空文件写入内容,'a'模式追加内容,最终文件内容为HelloWorld。