Given a character, you just need to keep the valid Chinese characters or letters, numbers and the like. When you remove a special symbol or split it in some format, you can use the Re.split method. For example
=============================== Restart:shell ===============================>>> s =" "Python 3.6.1 (V3.6.1:69C0DB5, Mar, 18:41:36) [MSC v.1900-bit (AMD64)] on Win32type "copyright", "Credits" O R "license ()" For more information." ">>>s'Python 3.6.1 (V3.6.1:69C0DB5, Mar, 18:41:36) [MSC v.1900-bit (AMD64)] on Win32\ntype "copyright", "credits" or "license ()" For more information.'>>>#now to split the S, remove the extra characters, only the numbers, letters, these valid characters. >>> >>>ImportRe>>> x = Re.split (r'[.(:,[)" ]', s)#Enter special symbols and spaces as split conditions['Python','3','6','1',"','v3','6','1','69C0DB5',"','Mar',' +',' .',"',' -',' A',' $',"',"','MSC','v','1900',' -','bit',"','AMD64',']',' on','Win32\ntype',"','Copyright',"',"',"','credits',"','or',"','License',"',"',"',' for',' More','Information',"']>>> >>> words = [i forIinchXifi]>>>words['Python','3','6','1','v3','6','1','69C0DB5','Mar',' +',' .',' -',' A',' $','MSC','v','1900',' -','bit','AMD64',']',' on','Win32\ntype','Copyright','credits','or','License',' for',' More','Information']>>>
Use the S.join () method to splice:
>>>#concatenation of Strings>>> >>>Help (Str.join)-on Method_descriptor:join (...) S.join (iterable)-str Return a string which isThe concatenation of the stringsinchThe iterable. The separator between elements isS.>>> L = List (range (1,9))>>> >>> s ="". join ([Str (i) forIinchl])>>>s'12345678'>>> s ="". Join (STR (i) forIinchl)>>>s'12345678'>>>
Python base = = = Split string, and concatenation string