注意:指令在後續版本略有修改,建議閱讀專案 README。
這篇文章會簡單描述如何使用 SNAFU Python installer manager。
這個專案源自我對社群不懂 Windows 又愛亂教的不滿。如果有興趣讀相關故事,以及一些背後邏輯,可以參考我在碼天狗上的抱怨文。
注意:指令在後續版本略有修改,建議閱讀專案 README。
這篇文章會簡單描述如何使用 SNAFU Python installer manager。
這個專案源自我對社群不懂 Windows 又愛亂教的不滿。如果有興趣讀相關故事,以及一些背後邏輯,可以參考我在碼天狗上的抱怨文。
| * { | |
| font-family: sans-serif; | |
| } | |
| h2 { | |
| font-size: 200%; | |
| margin-bottom: 4px; | |
| text-align: center; | |
| border-bottom: 1.4px solid; | |
| padding-bottom: 8px; | |
| } |
知道一個數字是不是質數的方法是:
如果 n 不是質數,那麼 n 一定有一個小於等於 n 的因數。
所以我們可以用下面的程式判斷輸入的 n 是否為質數:
def is_prime(n):
for i in range(2, n):
if n % i == 0: # 整除,i 是 n 的因數,所以 n 不是質數。Qt 在 Raspberry Pi 上可以跑兩種版本:
這個教學會編譯桌面版,因為我對這個版本比較熟。我上次試的時候 OpenGL 在 embedded 版還有些問題,不過 Qt 在那之後有很多更新,狀況應該會好很多。Qt 官方 wiki 也有個相關的教學:
| body { | |
| counter-reset: equation; | |
| } | |
| .MathJax_Display:after { | |
| font-family: serif; | |
| counter-increment: equation; | |
| content: "(" counter(equation) ")"; | |
| position: absolute; | |
| right: 0; | |
| } |
注意:需要用 Qt 5 跑。Qt 4 要稍微改一下 .pro 檔。
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import weakref | |
| __all__ = ['CObjectWrapper'] | |
| # Keeps a reference to all wrapper instances so that we can dealloc them when | |
| # we need to. |
| def _show_items(items): | |
| template = '{name:20}{price:>5}' | |
| if not items: | |
| print("No items. Use 'add' to add some!") | |
| return | |
| print() | |
| print(template.format(name='Item', price='Price')) | |
| print('-' * 25) | |
| for item in items: | |
| print(template.format( |
| import functools | |
| class Api: | |
| def __init__(self): | |
| self.apis = [] | |
| def register(self, f): | |
| self.apis.append(f.__name__) |