文字列の書式指定 / %、format()
参考:
- Programming the BBC micro:bit: Getting Started with MicroPython, p.67
- The Official BBC micro:bit User Guide, p.144-145
a, b = "hello", "world" c, d = "pine", "apple" print("%s" % a) print("%s, %s" % (a, b)) # 文字列オブジェクトに format() メソッドを適用する形でもよい。 print("{}".format(c)) print("{}, {}".format(c, d))
実行結果: