在一行上输入一个长度为
的字符串
,代表给定的密码。
在一行上输出一个字符串,代表变换后的密码。
NowCoder123
o69d6337123
import sys mima = {'abc': 2, 'def': 3, 'ghi': 4, 'jkl': 5, 'mno': 6, 'pqrs': 7, 'tuv': 8, 'wxyz': 9} translated_mima = '' for line in sys.stdin: a = line.split() for s in a[0]: if s.islower() == True: for keys in mima.keys(): if s in keys: translated_mima = translated_mima + str(mima[keys]) elif s.isupper() == True: if s != 'Z': s = chr(ord(s) + 33) else: s = 'a' translated_mima = translated_mima + s else: translated_mima = translated_mima + s print(translated_mima)
password = input() New_pass = '' beta = 'abc def ghi jkl mno pqrs tuv wxyz' for alp in password: if alp.isalpha(): if alp.isupper() and alp != 'Z': New_pass += str(chr(ord(alp.lower()) + 1)) elif alp == 'Z': New_pass += 'a' elif alp.islower(): for i,j in enumerate(beta.split()): if alp in j: New_pass += str(i + 2) else: New_pass += alp print(New_pass)
import sys for line in sys.stdin: a = line.split() str_input = a[0] change_dict = {"1":1,"a":2,"b":2,"c":2,"d":3,"e":3,"f":3,"g":4,"h":4,"i":4, "j":5,"k":5,"l":5,"m":6,"n":6,"o":6,"p":7,"q":7,"r":7,"s":7, "t":8,"u":8,"v":8,"w":9,"x":9,"y":9,"z":9,"0":0} result = "" for i in str_input: if(i.isupper()): #先转化小写 up_i = i.lower() #转化码 ac2_up_i = ord(up_i) if(ac2_up_i == ord("z")): ac2_up_i = ord("a") result = result + chr(ac2_up_i) else: result = result + chr(ac2_up_i+1) elif(i.isdigit()): result = result + str(i) else: result = result + str(change_dict[i]) print(result)
# 输入一串字符 str1 = list(input()) # 输入的转化为列表 # 注意这里不能直接把输入的进行切分成列表 # str1 = input().strip()#这样是错误的写法 # 定义一个用于存储变量的 temp = '' # 遍历列表 for i in str1: # 分成三种情况:小写,大写,数字 # 首先解决是小写子母的 if i.islower(): # 小写 abc_list = ["a","b","c"] def_list = ["d","e","f"] ghi_list = ["g","h","i"] jkl_list = ["j","k","l"] mon_list = ["m","o","n"] pqrs_list = ["p","q","r","s"] tuv_list = ["t","u","v"] wxyz_list = ["w","x","y","z"] if i in abc_list: i = "2" temp = temp + i elif i in def_list: i = "3" temp = temp + i elif i in ghi_list: i = "4" temp = temp + i elif i in jkl_list: i = "5" temp = temp + i elif i in mon_list: i = "6" temp = temp + i elif i in pqrs_list: i = "7" temp = temp + i elif i in tuv_list: i = "8" temp = temp + i elif i in wxyz_list: i = "9" temp = temp + i # elif a.isnumeric(): # 大写: elif i.isupper(): # 大写 # 把大写的转化成小写字母 i = i.lower() # 使用ascall码进行加一转化 i_ascall = ord(i) + 1 # 如果是123的ascall码那么要把它变成a的,也就是对应z的ascall码+1 if i_ascall == 123: i_ascall = ord("a") i = chr(i_ascall) # 在把ascall码转换回字母完成转化 temp = temp + i # 如果是数字,那么可以直接使用 elif i.isalnum(): # 数字 i = str(i) # 把数字转化成字符串,否则无法拼接 temp = temp + i print(temp)
def encryption(string): dct = {} key = 'ZABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz1234567890' value = 'abcdefghijklmnopqrstuvwxyz222333444555666777788899991234567890' for i,s in enumerate(key): k, v = s, value[i] dct[k] = v for i in string: print(dct[i], end='') encryption(input())
password_0 = input() pas=[] for i in password_0: if i in 'abc': pas.append('2') elif i in 'def': pas.append('3') elif i in 'ghi': pas.append('4') elif i in 'jkl': pas.append('5') elif i in 'mno': pas.append('6') elif i in 'pqrs': pas.append('7') elif i in 'tuv': pas.append('8') elif i in 'wxyz': pas.append('9') elif i.isupper() and i != 'Z': pas.append(chr(ord(i.lower())+1)) elif i=='Z': pas.append('a') else: #i.isdigit()判断为数字,此处else包含数字和其他字符 pas.append(i) print(''.join(pas))
s = input() a = [] zhimu = "abcdefghijklmnopqrstuvwxyz" for i in range(len(s)): a.append(s[i]) if a[i] in 'abc': a[i] = 2 elif a[i] in 'def': a[i] = 3 elif a[i] in 'ghi': a[i] = 4 elif a[i] in 'jkl': a[i] = 5 elif a[i] in 'mno': a[i] = 6 elif a[i] in 'pqrs': a[i] = 7 elif a[i] in 'tuv': a[i] = 8 elif a[i] in 'wxyz': a[i] = 9 elif a[i].isupper(): if a[i] !='Z': b = a[i].lower() indec = zhimu.index(b) # print(indec) a[i] = zhimu[indec+1] # print(a[i]) if a[i] == 'Z': a[i] = 'a' else: a[i] = a[i] # print(a) pp = '' for i in a: pp = pp+str(i) print(pp)
def str_tran(get_str): lst_str = [] for i in get_str: lst_str.append(i) for j in range(len(lst_str)): if ord(lst_str[j]) == ord('Z'): lst_str[j] = 'a' elif ord(lst_str[j]) >= 65 and ord(lst_str[j]) < 90: lst_str[j] = chr(ord(lst_str[j])+32+1) elif lst_str[j] in 'abc': lst_str[j] = '2' elif lst_str[j] in 'def': lst_str[j] = '3' elif lst_str[j] in 'ghi': lst_str[j] = '4' elif lst_str[j] in 'jkl': lst_str[j] = '5' elif lst_str[j] in 'mno': lst_str[j] = '6' elif lst_str[j] in 'pqrs': lst_str[j] = '7' elif lst_str[j] in 'tuv': lst_str[j] = '8' elif lst_str[j] in 'wxyz': lst_str[j] = '9' return ''.join(lst_str) get_str = input() print(str_tran(get_str))
while True: try: code_input = input() code_output = "" for element in code_input: if element.isdigit(): code_output += element elif element.isalpha(): if "A"<=element<"Z": element = chr(ord(element.lower())+1) code_output += element elif element == "Z": code_output += "a" elif element in "abc": code_output += "2" elif element in "def": code_output += "3" elif element in "ghi": code_output += "4" elif element in "jkl": code_output += "5" elif element in "mno": code_output += "6" elif element in "pqrs": code_output += "7" elif element in "tuv": code_output += "8" elif element in "wxyz": code_output += "9" print(code_output) except: break