Search code examples
pythonsplitlatitude-longitude

Python: Split a string by "/" slash symbol


I have a lat/lng string:

"31.20/121.36"

How do I split it by the "/" symbol?


Solution

  • You can use the .split() function in order to cut it into two parts and it inserts them into a list.

    text = "31.20/121.36"
    
    print(text.split("/"))
    

    This outputs ['31.20', '121.36'].