![]() |
I wrote a Python function a little while back that converts strings to numbers, for an app I was developing (which is currently on hold). It simply pulls out all the crap that isn't a number - for example, "8v52.x3" will become 852.3. It allows you to specify the return type - string, long integer or floating-point. Take a look:
:
def str2num (str, retType = ""): |
looks good, I'll have to check it out ;)
|
Actually, Thanks! I was just looking for something to change strings to ints. It works like a charm! Now you can have the satisfaction of knowing somebody actually used your code for something! How often does that happen!?! (if you're not a pro-programmer, not often ^_^ )
|
Heh. It's nice to know.
|
Solid and Simple Code Mate!
That is often quite useful, I made a small scrip that converted an IP addir to a simple int for my IP scanner, was almost the same code as your's Beeg |
Heh. 'Twould be slightly different - different purposes, different code. Glad to hear it looks clean though.
|
| All times are GMT -5. The time now is 8:08 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC