LoginSignup
0
0

More than 3 years have passed since last update.

python3のprint()で改行しない方法

Last updated at Posted at 2020-04-24

print関数のendオプションを使う

Python3 で print()すると、 通常改行される。
print("hello world", end="") とすれば、改行されない。

Arduino IDEだと println() と print()を使い分けて 
print文で出力した値のあとに改行するかしないかを指定しているけど、
pythonだとどうしているのかなぁと思って調べてみた。

end オプションは、奥が深そうだ。 cr、lfとかのコントロールもできるのかな?
ほかにも、sep 区切り文字、  file ファイルの指定、 flush バッファの強制出力、などがあるようだ。
ハードウェアに近い部分のプログラムを作るときに関係ありそう。
今の時点は、この程度の調査でどどめておこう。
(現場からは以上です。)

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