Last change
on this file was d7662b5, checked in by ManuelTrajcev <manueltrajcev7@…>, 3 weeks ago |
init
|
-
Property mode
set to
100644
|
File size:
347 bytes
|
Rev | Line | |
---|
[d7662b5] | 1 | # Open the file with UTF-16 encoding, which handles the BOM and null bytes.
|
---|
| 2 | with open("models.py", "r", encoding="utf-16") as f:
|
---|
| 3 | content = f.read()
|
---|
| 4 |
|
---|
| 5 | # Now write it back to the file as UTF-8, which should not have null bytes.
|
---|
| 6 | with open("models.py", "w", encoding="utf-8") as f:
|
---|
| 7 | f.write(content)
|
---|
| 8 |
|
---|
| 9 | print("File has been re-encoded to UTF-8.")
|
---|
Note:
See
TracBrowser
for help on using the repository browser.