简体   繁体   中英

python: stringarray to formatted string

I'm trying to create a text from an array for creating a kml using this example , in the following lines:

KML.coordinates(
              "146.825,12.233,400 "
              "146.820,12.222,400 "
              "146.812,12.212,400 "
              "146.796,12.209,400 "
              "146.788,12.205,400"
            )

I have this coordinates in an array already as strings like this:

myCoords[0]: '146.825,12.233,400'
myCoords[1]: '146.820,12.222,400'
...

but if I give myCoords to KML.coordinates , i'll get a blob without new lines and with [] enclosing it.

I can use ', '.join(myCoords) to remove the [] , but it still a blob without new lines. How can I do this?

Thanks!

The example uses space separated data; the string literals have newlines between them, but Python joins those together.

In any case, you can use ' '.join(myCoords) to join your coordinates in the same manner as that example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM