Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

Errore Test HW4

Valerio_01 (600 points)
2 6 10
in HW4 obbligatorio by (600 points)
closed by
Salve a tutti stavo iniziando a testare il mio codice e dopo aver superato tranquillamente i primi due test chiamati esempio passa ai randomici pero appena incontra il primo mi presenta questo errore, qualche idea?

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 66: character maps to <undefined>
420 views
closed with the note: usate encoding='utf8'

1 Answer

AdSum (16290 points)
9 20 134
by (16.3k points)
E' un problema di decodifica che si ha su windows, alla funzione open("filename") aggiungi encoding="utf8" cosi --> open("filename",encoding="utf8")
g
giacomo_venturini (6680 points)
3 6 40
by (6.7k points)
aggiungo che, mentre su windows è necessario, prima di consegnare bisogna togliere l'encoding o tutti i test andranno in errore
G
Giordano_Dionisi (3100 points)
16 41 59
by (3.1k points)
Teoricamente è solo una cosa in più, quindi sulla consegna nella macchina virtuale (Linux) non dovrebbero crearsi problemi
AdSum (16290 points)
9 20 134
by (16.3k points)
non dovrebbe dare errori, stai solo specificando una cosa gia presa di default, è come fare  x=0 quando x gia vale 0. E' solo ridondante.
g
giacomo_venturini (6680 points)
3 6 40
by (6.7k points)
l'ho provato e da errore specificando l'encoding, sennò non l'avrei scritto
AdSum (16290 points)
9 20 134
by (16.3k points)
Avrai sbagliato te, il professore l'ha fatto vedere e ha specificato il problema. Lui ha linux e andava tutto liscio, controlla bene.
G
Giordano_Dionisi (3100 points)
16 41 59
by (3.1k points)
Penso che il problema sia sorto sulla tua macchina esclusivamente in realtà
Valerio_01 (600 points)
2 6 10
by (600 points)
anche a me presenta questo tipo di errore, qualcuno ha risolto?

allego l'errore qui sotto:

encoding = 'uft8'

    def search_function(encoding):

        # Cache lookup
        entry = _cache.get(encoding, _unknown)
        if entry is not _unknown:
            return entry

        # Import the module:
        #
        # First try to find an alias for the normalized encoding
        # name and lookup the module using the aliased name, then try to
        # lookup the module using the standard import scheme, i.e. first
        # try in the encodings package, then at top-level.
        #
        norm_encoding = normalize_encoding(encoding)
        aliased_encoding = _aliases.get(norm_encoding) or \
                           _aliases.get(norm_encoding.replace('.', '_'))
        if aliased_encoding is not None:
            modnames = [aliased_encoding,
                        norm_encoding]
        else:
            modnames = [norm_encoding]
        for modname in modnames:
            if not modname or '.' in modname:
                continue
            try:
                # Import is absolute to prevent the possibly malicious import of a
                # module with side-effects that is not in the 'encodings' package.
>               mod = __import__('encodings.' + modname, fromlist=_import_tail,
                                 level=0)
E                                TypeError: _check_import() got an unexpected keyword argument 'fromlist'

..\..\anaconda3\lib\encodings\__init__.py:98: TypeError