Home > Enterprise >  casting to int python with symbol
casting to int python with symbol

Time:02-12

so I want to cast these to ints but when I use the built-in function int() I get an error, I don't want to make a custom function that checks the first character,so I was wondering if there was a way to convert these to ints.

error strings

CodePudding user response:

From what we found in the discussion under your question:

You have the mathematical unicode symbol "minus sign" instead of the ASCII symbol "hyphen-minus" in your string.

The problem can be solved by replacing the non-workning symbol with the working one:

int(CDMAOutput[idx].replace(chr(8722), '-')))
  • Related