python - ValueError: invalid literal for float(): "320" for a normal string -
i encountered strange problem: try turn string float , str this:
str(float(tmp[1])/100) # tmp[1] contain str
but throw out valueerror: invalid literal float(): "320"
so try this:
try: line_split[list_index] = str(float(tmp[1])/100) except: print >> sys.stderr, repr(tmp[1])
also, same error, , print '"320"'
any help? thanks!
the issue might sort of non-printing character that's present in value using. looks you're using python 2.x, in case can check them this:
print repr(tmp[1])
you'll see in there that's escaped in form \x00. these non-printing characters don't show when print directly console, presence enough negatively impact parsing of string value float.
Comments
Post a Comment