正确答案: B
### 2. 第 2 题:字符串大小写转换
知识点描述:将字符串中的字母进行大小写的转换是文本处理中常见的操作。
问题描述:将字符串中每个单词首字母转换为大写字母,请从以下选项中选出你认为正确的答案:
A.
string = ‘Learn PYTHON from beginner to exPERT!’
result = string.upper()
print(result)
B.
string = ‘Learn PYTHON from beginner to exPERT!’
result = string.capitalize()
print(result)
C.
string = ‘Learn PYTHON from beginner to exPERT!’
result = string.lower().capitalize()
print(result)
D.
string = ‘Learn PYTHON from beginner to exPERT!’
result = string.title()
print(result)
正确答案: D
### 3. 第 3 题:字符串开头或结尾匹配
知识点描述:通过指定的文本模式检查字符串的开头或者结尾。
问题描述:请从以下选项中选出输出为 True 的选项:
A.
choices = ‘http:’
url = “https://blog.csdn.net/LOVEmy134611”
result = url.startswith(choices)
print(result)
B.
choices = [‘http:’, ‘https:’]
url = “https://blog.csdn.net/LOVEmy134611”
result = url.startswith(choices)
print(result)
C.
choices = [‘http:’, ‘https:’]
url = “https://blog.csdn.net/LOVEmy134611”
result = url.startswith(tuple(choices))
print(result)
D.
choices = ‘https:’
url = “https://blog.csdn.net/LOVEmy134611”
result = url.endswith(choices)
print(result)
正确答案: C
### 4. 第 4 题:字符串匹配和搜索
知识点描述:匹配或者搜索特定模式的文本。
问题描述:请从以下选项中选出能够正确搜索 “Python” 第一次出现位置的答案:
A.
string = “Python is very simple, Let’s learn Python together”
result = string.startswith(‘Python’)
print(result)
B.
string = “Python is very simple, Let’s learn Python together”
result = string.rfind(‘Python’)
print(result)
C.
string = “Python is very simple, Let’s learn Python together”
result = string.find(‘Python’)
print(result)
D.
string = “Python is very simple, Let’s learn Python together”
result = string.find(‘python’)
print(result)
正确答案: C
### 5. 第 5 题:字符串替换
知识点描述:在字符串中搜索和匹配指定的文本,并进行使用其它字符进行替换。
问题描述:请从以下选项中选出能够正确将第一次出现的 “better” 替换为 “worse” 的答案:
A.
string = “”“Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.”“”
index = string.find(‘better’)
result = string.replace(‘better’, ‘worse’, 1)
print(result)
B.
string = “”“Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.”“”
index = string.find(‘better’)
result = string.replace(‘better’, ‘worse’, 0)
print(result)
C.
string = “”“Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.”“”
index = string.find(‘better’)
result = string.replace(‘better’, ‘worse’, -1)
print(result)
D.
string = “”“Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.”“”
result = string.replace(‘better’, ‘worse’)
print(result)
正确答案:A
### 6. 第 6 题:删除字符串中不需要的字符
知识点描述:去掉文本字符串开头,结尾或者中间不需要的字符。
问题描述:请从以下选项中选出能够正确去除开头和结尾空白字符(空白字符包括空格、换行符和 tab 键)的选项:
A.
string = " \n Beautiful is better than ugly. \n "
result = string.replace(‘\n’, ‘’)
print(result)
B.
string = " \n Beautiful is better than ugly. \n "
result = string.rstrip()
print(result)
C.
string = " \n Beautiful is better than ugly. \n "
result = string.strip(’ ')
print(result)
D.
string = " \n Beautiful is better than ugly. \n "
result = string.lstrip().rstrip()
print(result)
正确答案:D
### 7. 第 7 题:字符串对齐
知识点描述:通过指定的对齐方式来格式化字符串。
问题描述:将给定字符串居中,并指定返回字符串长度为40,使用等号("=")进行填充,请从以下选项中选出你认为正确的答案:
A.
string = “Beautiful is better than ugly.”
result = string.center(len(string)+40, ‘=’)
print(result)
B.
string = “Beautiful is better than ugly.”
result = string.center(40, ‘=’)
print(result)
C.
string = “Beautiful is better than ugly.”
result = string.rjust(40,‘=’)
print(result)
D.
string = “Beautiful is better than ugly.”
result = string.ljust(40,‘=’)
print(result)
正确答案:B
### 8. 第 8 题:字符串分割
知识点描述:将一个大的字符串分割为若干个小的字符串。
问题描述:将给定字符串划分为单词,并将单词首字母大写,请从以下选项中选出你认为正确的答案:
A.
string = ‘Beautiful is better than ugly.’
result = string.split()
result = [i.strip(‘.’) for i in result]
print(result)
B.
**一、Python所有方向的学习路线**
Python所有方向的技术点做的整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照下面的知识点去找对应的学习资源,保证自己学得较为全面。
![img](https://img-blog.csdnimg.cn/1d40facda2b84990b8e1743f5487d455.png)
![img](https://img-blog.csdnimg.cn/0fc11d4a31bd431dbf124f67f1749046.png)
**二、Python必备开发工具**
工具都帮大家整理好了,安装就可直接上手!![img](https://img-blog.csdnimg.cn/ff266f529c6a46c4bc28e5f895dec647.gif#pic_center)
**三、最新Python学习笔记**
当我学到一定基础,有自己的理解能力的时候,会去阅读一些前辈整理的书籍或者手写的笔记资料,这些笔记详细记载了他们对一些技术点的理解,这些理解是比较独到,可以学到不一样的思路。
![img](https://img-blog.csdnimg.cn/6d414e9f494742db8bcc3fa312200539.png)
**四、Python视频合集**
观看全面零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。
![img](https://img-blog.csdnimg.cn/a806d9b941c645858c61d161aec43789.png)
**五、实战案例**
纸上得来终觉浅,要学会跟着视频一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。![img](https://img-blog.csdnimg.cn/a353983317b14d3c8856824a0d6186c1.png)
**六、面试宝典**
![在这里插入图片描述](https://img-blog.csdnimg.cn/97c454a3e5b4439b8600b50011cc8fe4.png)
![在这里插入图片描述](https://img-blog.csdnimg.cn/111f5462e7df433b981dc2430bb9ad39.png)
###### **简历模板**![在这里插入图片描述](https://img-blog.csdnimg.cn/646863996ac44da8af500c049bb72fbd.png#pic_center)
**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
**[需要这份系统化学习资料的朋友,可以戳这里无偿获取](https://bbs.csdn.net/topics/618317507)**
**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**