Skip to content

Instantly share code, notes, and snippets.

@holmeszyx
Created June 14, 2012 13:55
Show Gist options
  • Select an option

  • Save holmeszyx/2930449 to your computer and use it in GitHub Desktop.

Select an option

Save holmeszyx/2930449 to your computer and use it in GitHub Desktop.
sub
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
def subString(str, s, e):
sPos = str.find(s)
if sPos == -1:
return None
sLen = len(s)
ePos = str.find(e, sPos + sLen)
print sPos, ePos
return str[sPos + sLen : ePos]
if __name__ == '__main__':
str = u"Alt + F1 类似Windows下的Win键,在GNOME中打开应用程序菜单(Applications) "
print type(str)
s = subString(str.encode("utf8"), u"类似".encode("utf8"), u"键".encode("utf8"))
print s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment