hell.py:
def parse_data(): with open(r"G:/人民幣貨幣對.txt",mode="r") as f: itle_list = f.readline().strip().split("\t") with open(r"G:/人民幣匯率中間價歷史資料.txt", mode="r", encoding="utf-8") as f: all_list = [] for line in f: line_list = line.strip().split("\t") all_list.append(line_list) return itle_list,all_list def parse_condition(condition,seq): column, value_s = condition.split(seq) ind = itle_list.index(column) for line_list in all_list: value_t = line_list[ind] yield value_t,value_s,condition def entry_point(): condition = input(">>> ") if (">" in condition): for value_t,value_s,condition in parse_condition(condition,">"): if value_t > value_s: print(value_t) if ("<" in condition ): for value_t, value_s, condition in parse_condition(condition, "<"): if value_t < value_s: print(value_t) if ("=" in condition ): for value_t, value_s, condition in parse_condition(condition, "="): if value_t == value_s: print(value_t) itle_list, all_list = parse_data() entry_point() input('輸入任意字元結束')
用pip install pyinstaller,然後pyinstaller -F hello.py,可以看到dist目錄有個hello.exe和__internal目錄(上面的檔案採用絕對路徑,改成相對路徑,將檔案放在__internal目錄),複製這兩個可點選使用