Skip to main content

No project description provided

Project description

Read Python3 Source File With Correct Encoding

according to https://www.python.org/dev/peps/pep-0263/, python3 source file encoding are default to be utf-8.

But open()'s encoding will be gbk on windows, So don't use open without encoding to read a python3 source file.

example:

from read_source import get_encoding, read
print(get_encoding('tests/source/gb18030/dash-star-dash.py')) # gb18030
with read('tests/source/gb18030/dash-star-dash.py') as f:
    print(f.read()) 
    # -*- coding: gb18030 -*-

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for read-source, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size read_source-0.0.2-py3-none-any.whl (1.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size read_source-0.0.2.tar.gz (1.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page