1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

visualstudioでpythonを扱う際の日本語出力

Last updated at Posted at 2017-02-07

初投稿です。
また、pythonも初心者なので間違った知識を持っていたらすみません。

本題に入りますとVisualStudioにおいてPythonでコンソールに日本語出力をする際には、単に文字コードを「"あいうえお".encode('utf-8')」という様に変換したり 「u"あいうえお"」という様に記述するだけでは私の環境ではエラーがでてしまいました。

色々調べてみますとpythonファイルの文字コードをutf-8に設定しなければならないみたいです。

日本版のVisualStudioではpythoファイルを作った際の初期の文字コードがshift-jisになっているようで、pythonファイルの設定を「ファイル→保存オプションの詳細設定→エンコードをutf-8」に変更すると無事に日本語が出力できるようになりました。

しかしファイルの文字コードの初期設定をshift-jisからutf-8に変更ができないようなので日本語を扱う際には毎回上記の手順が必要みたいです。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?