1. 程式人生 > 其它 >easygui 查詢文件內公司名稱

easygui 查詢文件內公司名稱

技術標籤:pythonpython

建立一個 company.txt 的檔案(使用utf-8格式) 裡面每行放入一家公司名稱

# -*- coding:utf-8 -*-
from easygui import *
import re


def find():
    fields_list = ['公司名稱']
    values_list = ["廈門"]
    com_name = multenterbox(msg = '帶*號的為必填項', title = '公司名稱查詢', fields = fields_list, values = values_list)

    find = []
    with open('company.txt', 'rb') as f:
        r = f.readlines()

    for com_find in r:
        com_findall = com_find.decode()
        com_findall_find = re.findall(com_name[0], com_findall)
        if com_findall_find == com_name:
            com_findall = com_findall.replace('\r', '').replace('\n', '')
            find.append(com_findall)



    yes_com = choicebox(msg = '查詢到的公司名稱', title = 'com_find', choices = find)
    return yes_com


def work(com_n):
    print(com_n)
    fields_list = ['公司名稱', '品名', '規格', '數量', '單位', '單價', '備註']
    values_list = [com_n, '自動獲取上次這家公司填寫的資訊', '', '', '', '', '']
    multenterbox(msg = '帶*號的為必填項', title = '公司名稱查詢', fields = fields_list, values = values_list)


company = find()
work(company)

# textbox(msg = '文字內容如下:', title = '文字檔案', text = company, codebox = 1)



在這裡插入圖片描述

在這裡插入圖片描述