使用 Python 将数字转换为相应的字母 [英] Convert numbers into corresponding letter using Python

查看:664
本文介绍了使用 Python 将数字转换为相应的字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将数字转换为其相应的字母值.所以

I was wondering if it is possible to convert numbers into their corresponding alphabetical value. So

1 -> a
2 -> b

我打算制作一个程序,列出用户指定长度的所有可能的字母组合.

I was planning to make a program which lists all the alphabetical combinations possible for a length specified by a user.

看我知道如何构建程序的其余部分,除了这个!任何帮助都会很棒.

See I know how to build the rest of the program except this! Any help would be wonderful.

推荐答案

Big Letter:

Big Letter:

chr(ord('@')+number)

1 -> A

2 -> B

...

小写字母:

chr(ord('`')+number)

1 -> 一个

2 -> b

...

这篇关于使用 Python 将数字转换为相应的字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆