From ae7b7f18a1e1cc1857f383275819238b91cb63af Mon Sep 17 00:00:00 2001 From: pwkgtv5a4 <204267667@qq.com> Date: Mon, 21 Mar 2022 20:22:16 +0800 Subject: [PATCH] ADD file via upload --- main.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..8b6bec4 --- /dev/null +++ b/main.py @@ -0,0 +1,25 @@ +from countword import count_word +from createcloud import create_cloud +from scanfiles import scan_files +import csv + + +if __name__ == "__main__": + filepath = 'files' # txt 文本存放路径 + scan_files(filepath) + file_no = input("Please select a file by the number in range:") + while file_no != 'E': + if not file_no.isnumeric(): # 判断是否是数字 + print("Input error!") + file_no = input("Please reselect a file by the number in range:") + else: # 读取序号对应的文件名 + with open('filename.csv', 'r', encoding='utf-8') as csvfile: + reader = csv.reader(csvfile) + for i in reader: + if file_no == i[0]: + print('Your choice:', i[1], end='\n') + filename = filepath + '\\' + i[1] + create_cloud(count_word(filename)) + scan_files(filepath) + else: # 判断file_no是否在范围内 + file_no = input("Please select a file by the number in range:")