2017-12-24から1日間の記事一覧
参考: Programming the BBC Micro:bit: Getting Started With MicroPython, pp.75-76 これまでに出てきた button_a や display は何らかのクラスのインスタンスである。どのクラスのインスタンスであるかは type() で確認できる。 ひとつのクラスは属性とメ…
参考: Programming the BBC micro:bit: Getting Started with MicroPython, p73-75 モジュールの中身を確認する。 from モジュール名 import * という構文でモジュールの中身を全部インポートする。 下のようにしてもモジュールの中身全部がインポートされる…
参考: Programming the BBC micro:bit: Getting Started with MicroPython, p.68-69 これだとインデックスが 5 を超えたところでエラーが出てプログラムが停止してしまう (Lua だと、存在しない要素を参照したときは nil が返ってくる)。 list = [0, 1, 2, 3…
参考: Programming the BBC micro:bit: Getting Started with MicroPython, p.69-71 from microbit import * with open("test.txt", "w") as sute: sute.write("ABC") with open("test.txt") as sute: message = sute.read() while True: display.scroll(mes…