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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for read_source-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5465b27edb4c45502ce74f8adeb3fa374f507ce0b57016de187ad46f9cd3c24 |
|
MD5 | 44f45dcb9f2d64248065baf64a30c641 |
|
BLAKE2b-256 | a4ffe1d00e14c4ef8f2b24f1e92ad4c17d33969eb09cec2590a442200015baa2 |