首页 > 解决方案 > Writing with Python Greek letters to (Oracle) SQL file doesn't work

问题描述

I'm trying to write Greek letters to file with ".sql" extension. But the result in the file are not correct.

The code in Python:

with open('test.sql', 'w', encoding='utf-8') as test_file:
    test_file.write('DH5α\n')

In the SQL file I get:

DH5α

Any way I can solve this?

OS is windows

Thanks.

标签: pythonsqlpython-3.xoracleoracle-sqldeveloper

解决方案


正如评论中所写,问题出在 sql-developer 本身,它默认不使用 utf-8 编码。


推荐阅读