pip install Gooey python from gooey import Gooey, GooeyParser python def count_words(filename): with open(filename, 'r') as file: text = file.read() word_count = len(text.split()) return word_count python @Gooey def main(): parser = GooeyParser(description="Word Count") parser.add_argument('filename', help="Select a text file", widget="FileChooser") args = parser.parse_args() word_count = count_words(args.filename) print(f'Total words: {word_count}') python if __name__ == '__main__': main() python from gooey import Gooey, GooeyParser def count_words(filename): with open(filename, 'r') as file: text = file.read() word_count = len(text.split()) return word_count @Gooey def main(): parser = GooeyParser(description="Word Count") parser.add_argument('filename', help="Select a text file", widget="FileChooser") args = parser.parse_args() word_count = count_words(args.filename) print(f'Total words: {word_count}') if __name__ == '__main__': main()


上一篇:
下一篇:
切换中文