python笔试面试项目实战2020百练13-去掉字符串中连续的
2020-10-16 本文已影响0人
python测试开发
字符串
字符串是 Python 中最常用的数据类型。我们可以使用引号('或")来创建字符串。
创建字符串很简单,只要为变量分配一个值即可。例如:
var1 = 'Hello World!'
var2 = "Python Runoob"
去掉字符串中连续的重复字母

2,编程题 -- 此题如能在本机(unbuntu)上调试出来更佳。
请使用python、java等定义一个函数或方法来去掉字符串中连续的重复字母,函数体以一行为佳。
以python为例:
print(no_consecutive_letters("PPYYYTTHON")) # 返回PYTHON
print(no_consecutive_letters("PPyyythonnn")) # 返回Python
print(no_consecutive_letters("Java")) # 返回Java
print(no_consecutive_letters("PPPHHHPPP")) # 返回PHP



参考资料
- 本文最新版本地址
- 本文涉及的python测试开发库 谢谢点赞!
- 本文相关海量书籍下载
- 源码地址 https://github.com/china-testing/python-testing-examples interview/drop_consecutive_letters.py
参考答案
