第五章测试
1.Which of the following statements cannot create a demo.txt file? ( )
A:f = open("demo.txt", "w") B:f = open("demo.txt", "x") C:f = open("demo.txt", "r") D:f = open("demo.txt", "a")
答案:C
2.After executing the following procedure, what content will be saved in the file?file=open('test.txt', 'wt+')file.write('hello SCUT')file.close()file=open('test.txt', 'at+')file.write('hello world')file.close() ( )
A:hello world B:hello SCUT hello world C:hello SCUThello world D:hello SCUT world 3.Which function is not the way Python reads files. ( )
A:readtext() B:read() C:readline() D:readlines() 4.How to rename a file in Python? ( )
A:os.rename(existing_name, new_name) B:fp.name = ‘new_name.txt’ C:os.rename(fp, new_name) D:os.set_name(existing_name, new_name) 5.What is the usage of tell() function in Python? ( )
A:tells you the current position within the file B:none of the mentioned C:tells you the end position within the file D:tells you the file is opened or not

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(6) dxwkbang
返回
顶部