Skip to content
Advertisement

Python String .strip() function returning wrong output

I have the following string

JavaScript

I am trying to get 256:0:10.0:34:26:-1478_B02_10m.tif from the string above

but if I run

JavaScript

It outputs '_B02_10m'

Same with filepath.rstrip('data/imagery/256:0:10.0:34:26:-1478')

Advertisement

Answer

Assuming you want all the string data after the / you can always use string.split. This spits your string into a list of strings split on the split string. Then you would only need the final item of this list.

JavaScript

See more official python docs on string.split here.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement