binfix | Java Bytecode Deobfuscation | Bytecode library
kandi X-RAY | binfix Summary
kandi X-RAY | binfix Summary
An open source java bytecode deobfuscator. This is meant to be a successor to the now unmaintained Java Deobfuscator project.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of binfix
binfix Key Features
binfix Examples and Code Snippets
Community Discussions
Trending Discussions on binfix
QUESTION
Let me start by saying that I know nothing about Python, but I am trying to learn(mostly through struggling it seems). I've looked around this site and tried to cobble together code to do what I need it to, but I keep running into problems. Firstly, I need to convert a file of 2 columns and 512 rows of strings to floats then put them in a 512x2 array. I check the first column (all rows) for negative values. If negative, add 512. Then I need to reorder the rows in numerical order and write/save the new array.
On to my first problem, converting to floats and putting the floats into an array. I have this code, which I made from others' questions:
with open("binfixtest.composite") as f:
f_values = map(lambda l: l.strip().split(' '), f)
print f_values
newarray = [map(float, v) for v in f_values]
Original format of file:
-91. 0.444253325
-90. 0.883581936
-89. -0.0912338793
New format of f_values:
['-91. 0.444253325'], ['-90. 0.883581936'], ['-89. -0.0912338793']
I'm getting the error:
Traceback (most recent call last):
File "./binfix.py", line 10, in
newarray = [map(float, v) for v in f_values]
ValueError: invalid literal for float(): -91. 0.444253325
which I can't seem to fix. If I don't convert to float, when I try to add 512.0 to negative rows it gives me the error TypeError: cannot concatenate 'str' and 'float' objects
Any help is most definitely appreciated as I am completely clueless here.
...ANSWER
Answered 2017-May-18 at 20:18@njzk2 is exactly right. Simply removing the literal spaces to change from l.strip().split(' ')
to l.strip().split()
will correct the error, and you will see the following output for f_values:
[['-91.', '0.444253325'], ['-90.', '0.883581936'], ['-89.', '-0.0912338793']]
And the output for newarray shows float values rather than strings:
Second Part:[[-91.0, 0.444253325], [-90.0, 0.883581936], [-89.0, -0.0912338793]]
For the second part of the question "if negative, add 512", a simple loop would be clear and simple, and I'm a big believer in clear, readable code.
For example the following is simple and straightforward:
for items in newarray:
if items[0] < 0:
items[0] += 512.00
When we print newarray
after the loop, we see the following:
[[421.0, 0.444253325], [422.0, 0.883581936], [423.0, -0.0912338793]]
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install binfix
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page