When I try to convert big numbers I get extra numbers at the end that doesn't move plus an L character too. How to remove the 4 extra characters at the end 000L?
8b8dbbc584d9c000L
8b8dc4ddd34c6000L
8b8dcdf621bf0000L
8b8dd70e7031a000L
8b8de026bea44000L
#!/usr/bin/python
import sys
def int_tuple_from_cmdline():
"""return exactly two integers form sys.argv
or die with an error message
"""
import sys
args = sys.argv[1:] # drop first entry (progpath)
if len(args) != 2:
raise SystemExit("\n#################################################\n# Please enter both a
start and stop parameter. #\n#################################################")
for i in range(len(args)):
try:
args = int(args)
except ValueError:
raise SystemExit("\n#################################################\n# Parameter %d is not an integer. You entered: %s #\n#################################################\n" %(i+1,args))
return tuple(args)
start, stop = int_tuple_from_cmdline()
r = start - 10000000000000
while r < stop:
r = r + 50000000000000
hx = hex(r)[2:]
print(hx)
Are you sure the zeros are not required because the middle one of the hex' values has 4 of them and the 'L' stands for LONG?
Also, as a guess, you must be using Python Version 2.x.x possibly 2.7.x and not 3.x.x.
So could you confirm your Python Version and OS it is running on...
Because I quoted that you remove the zeros at your own risk and did NOT put [:-4] at the end.
Again you remove those trailing zeros at YOUR OWN RISK, and that the middle one of your five results has 4 zeros and not 3 zeros.
This should be a pointer to tell you not to.
EDIT:
Please do not edit your post after a reply without letting people know what you have done in the edit box at the top of each post.
No one knows that you wanted to remove the zeros again and makes my reply look foolish...
You can shorten the cutting like this:
(Longhand using Python 2.7.x, OSX 10.14.6, default bash terminal.)
Last login: Mon Oct 14 15:15:55 on ttys000
AMIGA:amiga~> python
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x="0xabcdef123456"
>>> x=x[2:-6]
>>> print x
abcdef
>>> _