比如将字符串“dee4de0”转化成十六进制的dee4de0,该如何转化?谢谢
dee4de0
df5a40
df7630
df7cb60
df8b870
dfa5b40
dfbf6f0
dfc4270
dfc8b70
dfcd6f0
dfd7f0
dfe5500
dff6c50
e06c00
e01580
e023580
e024310
e062f40
e07b750
e0809e0
e086980
e0bb8a0
e0d7690
e0f8470
e0fa530
e12b4e0
e12e3b0
e12fee0
e134d60
e1398e0
e13e760
e17b4d0
e195720
e1b4df0
e1b5c80
e1dba00
7 个解决方案
#1
perl -e "print hex 'dee4de0'"
#2
$_ = 'ff';
print hex($_),"\n";
#3
应该是把16进制字符串转成整型值参与计算吧?10进制还是16进制只是针对字符串而言的,对计算机来说这都是同一个数。
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> int("dee4de0", 16)
233721312
>>> hex(int("dee4de0", 16))
'0xdee4de0'
>>>
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> int("dee4de0", 16)
233721312
>>> hex(int("dee4de0", 16))
'0xdee4de0'
>>>
#4
抱歉没看清楚是要perl,呵呵
#5
我的那些数据是大量的字符串,每次只能转换一个解决不了问题啊
#6
while (<DATA>) {
chomp;
printf("%s => %s \n", $_, hex($_) );
}
__DATA__
dee4de0
df5a40
df7630
df7cb60
df8b870
dfa5b40
dfbf6f0
dfc4270
dfc8b70
dfcd6f0
dfd7f0
dfe5500
dff6c50
e06c00
e01580
e023580
e024310
e062f40
e07b750
e0809e0
e086980
e0bb8a0
e0d7690
e0f8470
e0fa530
e12b4e0
e12e3b0
e12fee0
e134d60
e1398e0
e13e760
e17b4d0
e195720
e1b4df0
e1b5c80
e1dba00
#7
你这个不会的话,建议看一下《Perl语言入门》,有第四版中文版的。
#1
perl -e "print hex 'dee4de0'"
#2
$_ = 'ff';
print hex($_),"\n";
#3
应该是把16进制字符串转成整型值参与计算吧?10进制还是16进制只是针对字符串而言的,对计算机来说这都是同一个数。
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> int("dee4de0", 16)
233721312
>>> hex(int("dee4de0", 16))
'0xdee4de0'
>>>
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> int("dee4de0", 16)
233721312
>>> hex(int("dee4de0", 16))
'0xdee4de0'
>>>
#4
抱歉没看清楚是要perl,呵呵
#5
我的那些数据是大量的字符串,每次只能转换一个解决不了问题啊
#6
while (<DATA>) {
chomp;
printf("%s => %s \n", $_, hex($_) );
}
__DATA__
dee4de0
df5a40
df7630
df7cb60
df8b870
dfa5b40
dfbf6f0
dfc4270
dfc8b70
dfcd6f0
dfd7f0
dfe5500
dff6c50
e06c00
e01580
e023580
e024310
e062f40
e07b750
e0809e0
e086980
e0bb8a0
e0d7690
e0f8470
e0fa530
e12b4e0
e12e3b0
e12fee0
e134d60
e1398e0
e13e760
e17b4d0
e195720
e1b4df0
e1b5c80
e1dba00
#7
你这个不会的话,建议看一下《Perl语言入门》,有第四版中文版的。