如何将长度为4的字符串转换为十进制值? [英] How do I convert a string of length four into a decimal value?

查看:94
本文介绍了如何将长度为4的字符串转换为十进制值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将4个字母的字符串(可以是ASCII图表上的任何字符)转换为十进制值。例如:


- 十六进制值为62 65 61 6E的bean的值应为6736203616366.


- 我知道ord()但只适用于单个字符。


任何帮助都表示赞赏:]。

解决方案

将字符串分解为它的组件字符是使python很棒的事情之一。

展开 | 选择 | 换行 | 行号


< blockquote>顺便说一句,我不知道6736203616366来自哪里?!?它是什么?


http:/ /www.easycalculation.com/hex-converter.php


该值来自原始帖子中包含的字符串的十六进制表示。


哦哎呀,我忘了删除空格。我今天已经筋疲力尽了。 xD


1650811246是应该的值。


感谢您的帮助,我真的很感激:]。


I am trying to convert a 4 letter string (that can be of any character on the ASCII chart) into decimal values. For example:

- bean which has a hex value of 62 65 61 6E should have a value of 6736203616366.

- I know about ord() but that only works for single characters.

Any help is appreciated :].

解决方案

The ease of breaking up a string into it''s component characters is one of the things that makes python awesome.

Expand|Select|Wrap|Line Numbers


By the way, I can''t figure out where 6736203616366 comes from?!? What is it?


http://www.easycalculation.com/hex-converter.php

The value comes from the hex representation of the string I included with the original post.

Oh whoops, I forgot to remove spaces. I''ve been exhausted of all my energy today. xD

1650811246 is the value it should be.

Thanks for your help, I really appreciate it :].


这篇关于如何将长度为4的字符串转换为十进制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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