0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Macのpythonで、input()で日本語をBackspaceするとちゃんと消えない!

0
Posted at

事象

foo.pyの中でinput()したとき、日本語(全角文字)を打った後に1回backspaceすると半角分だけ消えて見える。backspaceの2回目でようやく1文字分消えたように見えるが、(Enterを押すなどして確かめると)実際は2文字分消えている。
インタプリタでinput()したときには同じ問題に遭遇しない。

今までWindowsで散々pythonを触っていたがこんなこと初めて。
最近Macを買った。使用しているpythonはpython3.9(OSデフォルト)。

偉大な記事

これと全く同じことが起こって、全く同じようにしたら治った

解決方法

該当pythonスクリプト(今回はfoo.py)の先頭にimport readlineを入れるだけ。

後記

こんなのどうやって検索すればいいんだ。今回はperplexity経由で発見

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?