凹凸雅思

file handling

使用闪卡高效复习COMPUTER-SCIENCE科目知识点

共计闪卡

10

闪卡自测

进度: 1 / 10已掌握: 0 | 需要复习: 0
问题

What is file handling?

点击查看答案
请先阅读问题,然后点击卡片查看答案

所有闪卡

闪卡 1

问题

What is file handling?

查看答案

答案

File handling is the use of programming techniques to work with information stored in text files.

闪卡 2

问题

List four examples of file handling techniques.

查看答案

答案

  1. Opening text files
  2. Reading text files
  3. Writing text files
  4. Closing text files.

闪卡 3

问题

In Python, how do you open a file named "fruit.txt" in read mode?

查看答案

答案

file = open("fruit.txt","r")

闪卡 4

问题

How do you close a file in Python?

查看答案

答案

file.close()

闪卡 5

问题

What does the "a" mode mean when opening a file in Python?

查看答案

答案

The "a" mode is for writing to the end of an existing file only (append).

闪卡 6

问题

True or False? ** The "w" mode in Python will create a new file if it doesn't exist.**

查看答案

答案

True. The "w" mode in Python will create a new file if it doesn't exist.

闪卡 7

问题

What is the purpose of the readline() function in Python?

查看答案

答案

The readline() function is used to read a single line from a file.

闪卡 8

问题

How do you write a new line to a file in Python?

查看答案

答案

file.write("New line content\n")

闪卡 9

问题

What does the following code do: endOfFile = name == ""

查看答案

答案

It checks if the end of the file has been reached by seeing if the 'name' variable is empty.

闪卡 10

问题

True or False? It's important to always make a backup of text files you are working with.

查看答案

答案

True. It's important to always make a backup of text files you are working with, as one mistake can cause you to lose the contents.