wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

6-文件操作

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

下列路径中,不属于相对路径的是

a)

./Python/filename.txt

b)

../Python/filename.txt

c)

C:/Python/filename.txt

d)

../../filename.txt

2.

open函数中,写入文件,但是不会覆盖文件的mode是

a)

r

b)

w

c)

x

d)

a

3.

open函数中,只有在文件不存在时才会创建并写文件的mode是

a)

r

b)

w

c)

x

d)

a

4.

根据下图展示的代码,返回的结果为:

a)

str

b)

tuple

c)

list

d)

dict

5.

根据下图展示的代码,返回的结果为:

a)

str

b)

tuple

c)

list

d)

dict

6.

处理python代码异常使用的代码块是:

a)

try-except

b)

if-else

c)

while

d)

for

7.

已知某个文本(gw.txt)中的内容为 'hello world' ,请问经过如下操作之后得到的文件中的内容为:

a)

hi

b)

''

c)

hillo world

d)

hello worldhi

8.

python中自带的进行目录基本操作的模块为

a)

file

b)

directory

c)

system

d)

os

9.

os模块中,创建文件夹的命令为:

a)

newdir

b)

mkdir

c)

getdir

d)

chdir

10.

下列不属于os模块中的目录操作方法的是:

a)

chdir

b)

getdir

c)

mkdir

d)

rmdir