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.

Source Distribution

read_source-0.0.2.tar.gz (1.5 kB view details)

Uploaded Source

Built Distribution

read_source-0.0.2-py3-none-any.whl (1.6 kB view details)

Uploaded Python 3

File details

Details for the file read_source-0.0.2.tar.gz.

File metadata

  • Download URL: read_source-0.0.2.tar.gz
  • Upload date:
  • Size: 1.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.5 Windows/10

File hashes

Hashes for read_source-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1890960201eaa90ab1a94b65e7d450d66df5474970ff3bcb7460ed20ae9af889
MD5 da36a7fcaf90a202cbd92906e1356902
BLAKE2b-256 5f303973a0dc0cb622b3c7568691f50a9863eb7645a010c4a8712dde5be7b762

See more details on using hashes here.

File details

Details for the file read_source-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: read_source-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.5 Windows/10

File hashes

Hashes for read_source-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5465b27edb4c45502ce74f8adeb3fa374f507ce0b57016de187ad46f9cd3c24
MD5 44f45dcb9f2d64248065baf64a30c641
BLAKE2b-256 a4ffe1d00e14c4ef8f2b24f1e92ad4c17d33969eb09cec2590a442200015baa2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page