我是靠谱客的博主 正直金毛,最近开发中收集的这篇文章主要介绍python程序exe运行字符出现问号_字符仅在行尾显示为菱形问号(Python> Text),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

I'm working on a Python file that inputs a text file with Japanese characters (UTF-8) in it, takes some of the text, and writes it into a new UTF-8 text file.

The problem I'm coming across is that for some reason whenever the Japanese character だ appears at the end of a line in the original input file, it comes out as a diamond question mark in the output file.

Instances of だ before the end of a line read perfectly fine and the original input file has it reading perfectly fine even if it's at the end of the line.

解决方案

As you haven't shared any code snippet I would recommend you a generic way of reading and writing utf-8 files using the codecs module as:

# Reading utf-8 encoded file

with codecs.open("in.txt", "r", encoding="utf-8") as input_data:

data = input_data.read()

# Write utf-8 encoded file

with codecs.open("out.txt", "w", encoding="utf-8") as output_data:

output_data.write(data)

And BTW I tested it on the given character だ and it works pretty fine.

最后

以上就是正直金毛为你收集整理的python程序exe运行字符出现问号_字符仅在行尾显示为菱形问号(Python> Text)的全部内容,希望文章能够帮你解决python程序exe运行字符出现问号_字符仅在行尾显示为菱形问号(Python> Text)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部