程式碼
#!/usr/bin/env python3 import sys from gi.repository import GLib try: path = "data.txt" content = "中文" GLib.file_set_contents(path, content.encode("utf-8")) except GLib.GError as e: print("Error: ", e.message) else: pass