本文主要是介绍PAT (Basic Level) Practice 1033 旧键盘打字 Python,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
根据题意,这道题让我们根据要求去除第二行输入的字符串中的部分内容
1.判断上档键是否损坏,以进行下一步处理
2.根据要求去除字符串中特定字符
3.sys模块:可用于大量输入的加速
4.operator:可用于运算时的加速
代码如下:
import sys
import operator
in_1=sys.stdin.readline()
in_2=sys.stdin.readline()
out_1=""
upper_str = in_1.upper()
lower_str = in_1.lower()
str_1 = "_,-.0123456789abcdefghijklmnopqrstuvwxyz"
if '+' in in_1:for i in in_2:if i not in lower_str:if operator.lt(i,'A') or operator.gt(i,'Z'):if i in str_1:out_1=out_1+i
else :for i in in_2:if i not in upper_str and i not in lower_str:out_1=out_1+i
print(out_1)
运行结果:
这篇关于PAT (Basic Level) Practice 1033 旧键盘打字 Python的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!