Is ‘encoding is an invalid keyword’ error inevitable in python 2.x?

For Python2.7, Use io.open() in both locations.

import io
import shutil

with io.open('/etc/passwd', encoding='latin-1', errors="ignore") as source:
    with io.open('/tmp/goof', mode="w", encoding='utf-8') as target:
        shutil.copyfileobj(source, target)

The above program runs without errors on my PC.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)