asistencias.py

Đang mở
#56 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
15/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

The pasted file is a Python attendance-control script, not code from this JavaScript/TypeScript repository, and the issue does not say what to change. The visible defects are a stray backtick in registrar_empleado (printi/n¨...), a backtick before from datetime import datetime at the top, and the label sALIDA in mostrar_registro. Confirm with the author what is wanted before editing, then run the script with python asistencias.py to check that it starts.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

from datetime import datetime

===================== CLASE EMPLEADO =====================

class Empleado:
def init(self, numero, nombre, puesto):
self.numero = numero
self.nombre = nombre
self.puesto = puesto
self.entrada = None
self.salida = None

def registrar_entrada(self):
    if self.entrada is None:
        self.entrada = datetime.now()
        print(f"\nEntrada registrada para: {self.nombre}")
        print(f"Hora: {self.entrada.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"\n {self.nombre} ya tiene una entrada registrada.")

def registrar_salida(self):
    if self.entrada is None:
        print(f"\n {self.nombre} no tiene entrada registrada.")
    elif self.salida is None:
        self.salida = datetime.now()
        print(f"\nSalida registrada para: {self.nombre}")
        print(f"🕐 Hora: {self.salida.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"\n {self.nombre} ya tiene una salida registrada.")

def mostrar_registro(self):
    print("\n" + "-" * 40)
    print(f"NÚMERO:  {self.numero}")
    print(f"NOMBRE:  {self.nombre}")
    print(f"PUESTO:  {self.puesto}")
    
    if self.entrada:
        print(f"ENTRADA: {self.entrada.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"ENTRADA: Sin registro")
    
    if self.salida:
        print(f"SALIDA:  {self.salida.strftime('%d/%m/%Y %H:%M:%S')}")
    else:
        print(f"sALIDA:  Sin registro")
    print("-" * 40)

===================== CLASE CONTROL DE ASISTENCIA =====================

class ControlAsistencia:
def init(self):
self.empleados = {}

def registrar_empleado(self):
    print("\n" + "=" * 40)
    print("       REGISTRAR EMPLEADO")
    print("=" * 40)
    
    numero = input("Número de empleado: ")
    
    if numero in self.empleados:
        `printi/n¨El empleado ya está registrado.")
        return
    
    nombre = input("👤 Nombre completo: ")
    puesto = input("💼 Puesto: ")
    
    self.empleados[numero] = Empleado(numero, nombre, puesto)
    print("✅ Empleado registrado correctamente.")

def buscar_empleado(self):
    print("\n" + "=" * 40)
    numero = input("🔢 Número de empleado: ")
    if numero in self.empleados:
        return self.empleados[numero]
    print("❌ Empleado no encontrado.")
    return None

def registrar_entrada(self):
    print("\n" + "=" * 40)
    print("       REGISTRAR ENTRADA")
    print("=" * 40)
    empleado = self.buscar_empleado()
    if empleado:
        empleado.registrar_entrada()

def registrar_salida(self):
    print("\n" + "=" * 40)
    print("        REGISTRAR SALIDA")
    print("=" * 40)
    empleado = self.buscar_empleado()
    if empleado:
        empleado.registrar_salida()

def mostrar_registros(self):
    print("\n" + "=" * 40)
    print("      LISTA DE REGISTROS")
    print("=" * 40)
    
    if not self.empleados:
        print("📭 No hay empleados registrados.")
        return
    
    for empleado in self.empleados.values():
        empleado.mostrar_registro()

===================== PROGRAMA PRINCIPAL =====================

def main():
sistema = ControlAsistencia()

while True:
    print("\n" + "=" * 40)
    print("    SISTEMA DE CONTROL DE ASISTENCIA")
    print("=" * 40)
    print(" 1 → Registrar empleado")
    print(" 2 → Registrar entrada")
    print(" 3 → Registrar salida")
    print(" 4 → Mostrar todos los registros")
    print(" 5 → Salir del sistema")
    print("=" * 40)
    
    opcion = input("👉 Elige una opción: ")
    
    if opcion == "1":
        sistema.registrar_empleado()
    elif opcion == "2":
        sistema.registrar_entrada()
    elif opcion == "3":
        sistema.registrar_salida()
    elif opcion == "4":
        sistema.mostrar_registros()
    elif opcion == "5":
        print("\n👋 Sistema finalizado. ¡Hasta luego!")
        break
    else:
        print("\n❌ Opción no válida. Intenta nuevamente.")

Ejecutar el programa

if name == "main":
main()

Ngôn ngữ chính
TypeScript
Star
104
Fork
36
Merge trung bình
4 ngày 23 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của serpapi/serpapi-javascript

Tất cả issue của serpapi/serpapi-javascript

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.