你好在客户预约表中选择课程时需要帮助

2024-07-04 13:34:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试构建一个基于文本的“客户”菜单,以进行自动约会和管理冲突。我正在使用Python,但到目前为止,我一直在使用过程编程(我是个新手),但它变得太复杂,无法维护。我想使用CSV文件来保存所有联系人(最多一千个)和calcurse来管理我的日历

基本上,我想检查一下联系人是否被批准,然后将我的可用性发送给他。我尝试使用datefinder模块获取日期&;时间,检查是否可用,并要求订购

我想知道我需要创建什么类:

import csv
import datetime
import time

class Contact:
    def __init__(self, index, name, last_time, last_level='unreliable', appdate=None, apporder=None, appnote=None):
        self.index = index
        self.name = name
        self.last_time = last_time #last time I received a message from this person to unlogg if it's 
                                    over 5min agoo
        self.last_level = last_level # can be unreliable,main,date,order,note as
                                     # unreliable= don't even send availibities
                                     # main=the person is logged send availibities
                                     # date=ask for date, order=ask for order, note=ask for note
        self.appdate = datetime.datetime.strptime(appdate, '%Y-%m-%d %H:%M').date()
        self.apporder = apporder
        self.appnote = appnote

class Appointment:
 # I'd like to create a class for all the appointments from the calcurse file listing all the appointments to be able to check for instances if any conflicts with any new appointments.

    def __init__(self, name, appdate, apporder, appnote):
        self.name = name
        self.appdate = datetime.datetime.strptime(appdate, '%Y-%m-%d %H:%M')
        self.apporder = apporder
        self.appnote = appnote

def find_contact_in_file(name):
    try:
        with open("contact", 'r') as csvfile:
            reader = csv.reader(csvfile)
            index = 0
            for line in reader:
                index += 1
                if line[0] == name:
                    print(index, line)
                    contact = Contact(index, line[0], line[1], line[2], line[3], line[4], line[5])
                    return contact
            return contact.Contact(index + 1, name, int(time.time()), "unreliable", None, None, None)
    except IOError:
        print("I/O error")

我是否需要一个类回复来回复我从客户那里收到的消息


Tags: tonameselfnonefordatetimeindextime

热门问题