将int转换为ASCII并返回Python

编程入门 行业动态 更新时间:2024-10-18 14:19:17
本文介绍了将int转换为ASCII并返回Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在为我的网站制作一个URL缩短器,而我目前的计划(我愿意接受建议)是使用节点ID来生成缩短的URL。因此,理论上,节点26可能是 short/z ,节点1可能是 short/a ,节点52可能是 short/Z ,节点104可能是 short/ZZ 。当用户访问该URL时,我需要反转该过程(显然)。

I'm working on making a URL shortener for my site, and my current plan (I'm open to suggestions) is to use a node ID to generate the shortened URL. So, in theory, node 26 might be short/z, node 1 might be short/a, node 52 might be short/Z, and node 104 might be short/ZZ. When a user goes to that URL, I need to reverse the process (obviously).

我可以想到一些方法可以解决这个问题,但我猜有更好的。有什么建议吗?

I can think of some kludgy ways to go about this, but I'm guessing there are better ones. Any suggestions?

推荐答案

ASCII到int:

ASCII to int:

ord('a')

给出 97

并返回字符串:

str(unichr(97))

给出'a'

更多推荐

将int转换为ASCII并返回Python

本文发布于:2023-06-08 21:29:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/589393.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   int   Python   ASCII

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!