Home > other > Python problems seek help from a great god
Python problems seek help from a great god
Time:11-28
1. Niuniu file extractor (6 points) Niuniu in the process of handling file found a file extractor app, the app can read both Chinese and English mixed files, and to pick up the inside of English, as a new file, but one day he found his own app trial period is over, we may not be able to use, please help him realize the function of this app, let him be able to deal with the files quickly,
CodePudding user response:
with the open (' input. TXT) as fp: String=fp. Read () With the open (' output. TXT ', 'w') as fp: Fp. Write ('. Join (char for char string in the if word (char) & lt; 128))
May need to be in oepn function parameters and encoding="utf-8" or encoding="GBK encoding specified file
CodePudding user response:
Didn't understand that, a great god
CodePudding user response:
The for loop a indentation
with the open (' input. TXT, encoding="utf-8") as fp: String=fp. Read () With the open (' output. TXT ', 'w') as fp: Fp. Write ('. Join (char for char string in the if word (char) & lt; 128))