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)

运行结果:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值