第五章测试
1.Which of the following statements cannot create a demo.txt file? ( )
A:f = open("demo.txt", "w")
B:f = open("demo.txt", "r")
C:f = open("demo.txt", "x")
D:f = open("demo.txt", "a")

答案:B
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 SCUThello world
B:hello SCUT hello world
C:hello SCUT world
D:hello world
3.Which function is not the way Python reads files. ( )
A:readlines()
B:readline()
C:read()
D:readtext()
4.How to rename a file in Python? ( )
A:os.rename(fp, new_name)
B:os.set_name(existing_name, new_name)
C:os.rename(existing_name, new_name)
D:fp.name = ‘new_name.txt’
5.What is the usage of tell() function in Python? ( )
A:tells you the current position within the file
B:tells you the end position within the file
C:none of the mentioned
D:tells you the file is opened or not

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