=============================== RESTART: Shell ===============================
>>> s = '''Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.'''
>>>s'Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32\nType "copyright", "credits" or "license()" for more information.'
>>> #现在要对s拆分,去掉里面多余的字符,只提取 数字,字母这些有效字符。
>>>
>>> importre>>> x = re.split(r'[.(:,[)" ]', s) #把特殊符号和空格都作为拆分条件输入['Python', '3', '6', '1', '', 'v3', '6', '1', '69c0db5', '', 'Mar', '21', '2017', '', '18', '41', '36', '', '', 'MSC', 'v', '1900', '64', 'bit', '', 'AMD64', ']', 'on', 'win32\nType', '', 'copyright', '', '', '', 'credits', '', 'or', '', 'license', '', '', '', 'for', 'more', 'information', '']>>>
>>> words = [i for i in x ifi]>>>words
['Python', '3', '6', '1', 'v3', '6', '1', '69c0db5', 'Mar', '21', '2017', '18', '41', '36', 'MSC', 'v', '1900', '64', 'bit', 'AMD64', ']', 'on', 'win32\nType', 'copyright', 'credits', 'or', 'license', 'for', 'more', 'information']>>>