Skip to content

Instantly share code, notes, and snippets.

@piyonishi
Created July 8, 2013 04:29
Show Gist options
  • Save piyonishi/5946228 to your computer and use it in GitHub Desktop.
Save piyonishi/5946228 to your computer and use it in GitHub Desktop.
# Pythonっぽい書き方
a = '1,2,3,4,5,'
# その1
p1 = [item for item in a.split(',') if not item == '']
print(p1)
#['1', '2', '3', '4', '5']
# その2
p2 = a.rstrip(',').split(',')
print(p2)
#['1', '2', '3', '4', '5']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment