我正在为我的网站制作一个 URL 缩短器,我目前的计划(我愿意接受建议)是使用节点 ID 来生成缩短的 URL。 So, in theory, node 26 might be short.com/z
, node 1 might be short.com/a
, node 52 might be short.com/Z
, and node 104 might be short.com/ZZ
.当用户访问该 URL 时,我需要反转该过程(显然)。
我可以想到一些笨拙的方法来解决这个问题,但我猜还有更好的方法。有什么建议么?
原文由 mlissner 发布,翻译遵循 CC BY-SA 4.0 许可协议
ASCII 到 int:
给出
97
回到一个字符串:
str(unichr(97))
chr(97)
给出
'a'