Fehler beim Ausführen des Python-Skripts: Der Codec „utf-8“ kann Byte 0xed in Position 79 nicht dekodieren: ungültiges FPython

Python-Programme
Anonymous
 Fehler beim Ausführen des Python-Skripts: Der Codec „utf-8“ kann Byte 0xed in Position 79 nicht dekodieren: ungültiges F

Post by Anonymous »

Code: Select all

C:\inetpub\wwwroot\proyecto_transporte>python conexion.py
Unexpected error: 'utf-8' codec can't decode byte 0xed in position 79: invalid continuation byte
Ich habe bereits versucht, die Datei als ANSI zu speichern, habe überprüft, ob sie als UTF-8 gespeichert ist, aber nichts scheint zu funktionieren. Ich weiß nicht, was ich sonst noch versuchen soll. Wenn jemand ein ähnliches Problem hatte, würde ich mich sehr über Ihre Hilfe freuen.
Hier ist der Inhalt meines Skripts:

Code: Select all

import psycopg2

def verificar_conexion():
try:
conexion = psycopg2.connect(
host="10.240.0.96",
database="transporte_dev",
user="postgres",
password="***********",
port="5432"
)

print("Conexion exitosa a PostgreSQL")

cursor = conexion.cursor()
cursor.execute("SELECT version();")
version = cursor.fetchone()
print(f"Version de PostgreSQL: {version[0]}")

cursor.close()
conexion.close()
print("Conexion cerrada correctamente")

return True

except psycopg2.OperationalError as e:
print(f"Error de conexion: {e}")
return False
except Exception as e:
print(f"Error inesperado: {e}")
return False

if __name__ == "__main__":
verificar_conexion()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post