wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Week 6 上周知识点回顾

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

如何在字符串中表示一个反斜杠?

a)

\

b)

/

c)

\\

d)

\/

2.

以下哪个是格式化字符串的正确用法?

a)

'他叫{name},今年{age}岁'.format(name='小明', age=18)

b)

'他叫{name},今年{age}岁'.format(name='小明')

c)

'他叫{name},今年{age}岁'.format(age=18)

d)

'他叫{name},今年{age}岁'.format()

3.

以下哪个方法可以删除字符串两侧的空白字符?

a)

join()

b)

split()

c)

replace()

d)

strip()

4.

在Python中,字符串对象是可变的吗?

a)

b)

不确定

c)

部分可变

d)

5.

使用哪个方法可以将列表中的元素连接成字符串?

a)

split()

b)

strip()

c)

replace()

d)

join()

6.

在Python中,如何打开一个文件进行写入?

a)

open('file.txt', 'r+')

b)

open('file.txt', 'a')

c)

open('file.txt', 'r')

d)

open('file.txt', 'w')

7.

在Python中,如何将字符串分割成列表?

a)

split()

b)

combine()

c)

join()

d)

partition()

8.

在Python中,如何读取文件的第一行?

a)

readline()

b)

read()

c)

readlines()

d)

firstline()

9.

在Python中,如何将字符串中的多个空白字符替换为一个空格?

a)

' '.join(x.split())

b)

x.replace(' ', ' ')

c)

x.split(' ')

d)

x.strip()

10.

在Python中,如何使用with语句管理文件?

a)

open('file.txt') with f:

b)

with open('file.txt') as f:

c)

with f open('file.txt'):

d)

open('file.txt') as with f: