zh3036 / codingQuestions

um, ask in pull request
7 stars 0 forks source link

Substitute number with letters #5

Closed AriadneLiu closed 7 years ago

AriadneLiu commented 7 years ago

''' I tried to substitute number with letters, such as 11=a, 12=b, etc. However, I do not want to use a for loop function and have to write so many if and elif. Could I use a dictionary to do that? Thanks! ''' ciphertext=['44 ', '54 ', '11 ', '34 ', '54 ', '11 ', '23 ', '33 ', '53 ', '44 ', '54 ', '12 ', '42 ', '43 ', '42 ', '44 ', '32 ', '51 ', '41 ', '21 ', '23 ', '11 ', '31 ', '13 ', '53 ', '15 ', '54 ', '42 ', '54 ', '42 ', '44 ', '42 ', '43 ', '44 ', '32 ', '51 ', '41 ', '53 ', '43 ', '54 ', '32 ', '42 ', '34 ', '41 ', '11 ', '25 ', '51 ', '35 ', '53 ', '34 ', '13 ', '42 ', '43 ', '22 ', '53 ', '43 ', '11 ', '44 ', '54 ', '34 ', '53 ', '43 ', '22 ', '51 ', '34 ', '31 ', '42 ', '14 ', '32 ', '51 ', '34 ', '12 ', '53 ', '34 ', '12 ', '15 ', '54 ', '15 ', '34 ', '51 ', '33 ', '51 ', '44 ', '44 ', '11 ', '22 ', '51 ', '44 ', '42 ', '54 ', '42 ', '44 ', '44 ', '15 ', '34 ', '51 ', '23 ', '55 ', '15 ', '43 ', '21 ', '34 ', '51 ', '11 ', '13 ', '11 ', '21 ', '23 ', '51 ', '42 ', '54 ', '31 ', '53 ', '33 ', '21 ', '42 ', '43 ', '51 ', '44 ', '53 ', '15 ', '34 ', '14 ', '34 ', '51 ', '25 ', '42 ', '53 ', '15 ', '44 ', '33 ', '51 ', '54 ', '32 ', '53 ', '41 ', '44 ', '34 ', '35 ', '13 ', '54 ']

notcome commented 7 years ago

Java 中字符本质是一个整数,字符和整数的对应关系遵循 ASCII 字符编码。该编码中,a、b、c、d……按顺序依次排列。欲完成你的目标,可以把密文数字 x 减上字符 a 对应的密文数字,加上 a 对应的 ASCII 编码,得到对应字母的 ASCII 编码。关于 ASCII 编码、整数、字符在 Java 中的转换,请自行阅读相关文档。

— 刘闽晟

On Sep 27, 2017 at 17:09, <AriadneLiu (mailto:notifications@github.com)> wrote:

''' I tried to substitute number with letters, such as 11=a, 12=b, etc. However, I do not want to use a for loop function and have to write so many if and elif. Could I use a dictionary to do that? Thanks! ''' ciphertext=['44 ', '54 ', '11 ', '34 ', '54 ', '11 ', '23 ', '33 ', '53 ', '44 ', '54 ', '12 ', '42 ', '43 ', '42 ', '44 ', '32 ', '51 ', '41 ', '21 ', '23 ', '11 ', '31 ', '13 ', '53 ', '15 ', '54 ', '42 ', '54 ', '42 ', '44 ', '42 ', '43 ', '44 ', '32 ', '51 ', '41 ', '53 ', '43 ', '54 ', '32 ', '42 ', '34 ', '41 ', '11 ', '25 ', '51 ', '35 ', '53 ', '34 ', '13 ', '42 ', '43 ', '22 ', '53 ', '43 ', '11 ', '44 ', '54 ', '34 ', '53 ', '43 ', '22 ', '51 ', '34 ', '31 ', '42 ', '14 ', '32 ', '51 ', '34 ', '12 ', '53 ', '34 ', '12 ', '15 ', '54 ', '15 ', '34 ', '51 ', '33 ', '51 ', '44 ', '44 ', '11 ', '22 ', '51 ', '44 ', '42 ', '54 ', '42 ', '44 ', '44 ', '15 ', '34 ', '51 ', '23 ', '55 ', '15 ', '43 ', '21 ', '34 ', '51 ', '11 ', '13 ', '11 ', '21 ', '23 ', '51 ', '42 ', '54 ', '31 ', '53 ', '33 ', '21 ', '42 ', '43 ', '51 ', '44 ', '53 ', '15 ', '34 ', '14 ', '34 ', '51 ', '25 ', '42 ', '53 ', '15 ', '44 ', '33 ', '51 ', '54 ', '32 ', '53 ', '41 ', '44 ', '34 ', '35 ', '13 ', '54 ']

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub (https://github.com/zh3036/codingQuestions/issues/5), or mute the thread (https://github.com/notifications/unsubscribe-auth/ACIShJypVNXnaz27hUM4XoSLP6Lqk5eqks5smuOlgaJpZM4Pmjwr).

notcome commented 7 years ago

默认问题已解决,关闭。