Last active
August 29, 2015 14:15
-
-
Save j0lvera/b82dd0681ccfa3284959 to your computer and use it in GitHub Desktop.
truncate text and add ellipsis '...'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/2872512/python-truncate-a-long-string | |
def short_text(data): | |
return (data[:10] + '..') if len(data) > 10 else data | |
print short_text('adaf adf adf adf asdf adff') | |
# >> adaf adf a.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment