Created
June 14, 2012 13:55
-
-
Save holmeszyx/2930449 to your computer and use it in GitHub Desktop.
sub
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
| #!/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