You can use the replace()
method in Python to replace the comma "," with a dot "." for float converting.
Here's an example:
main.py202 chars11 lines
In the above example, replace(",", ".")
replaces all occurrences of "," with "." in the float_str
variable. Then, you can use the float()
function to convert the modified string into a float.
Remember to ensure that the original string only contains valid float format, as replacing commas with dots is just a character manipulation and doesn't handle any other conversion requirements.
gistlibby LogSnag