- 不會太污染
PATH
- 盡可能避免要求 root/admin 權限
- 可以同時安裝多個版本(只需要到 minor,不須 patch)
- 可以輕鬆啟動任意一個版本的 Python,不須多餘設定,版本之間也不會互相衝突
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
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 上可以跑兩種版本:
- 桌面版。你平常在 Linux 發行版裡看到的會是這個,包含 Raspbian 在內。通常基於 X11,就是個普通的 GUI 框架。
- 嵌入版。這個版本不需要鐘面系統,通常是直接走 framebuffer 直接把東西畫到螢幕上,適合一些嵌入式設備的應用。
這個教學會編譯桌面版,因為我對這個版本比較熟。我上次試的時候 OpenGL 在 embedded 版還有些問題,不過 Qt 在那之後有很多更新,狀況應該會好很多。Qt 官方 wiki 也有個相關的教學:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
檔。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
class Api: | |
def __init__(self): | |
self.apis = [] | |
def register(self, f): | |
self.apis.append(f.__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Requirements: | |
' * Windows 7 or later. (Might work on Vista and XP.) | |
' * Python 3 installation. (Will prompt for installation path.) | |
' The installation path should be both readable and *writable*. | |
' * msysGit installation. | |
Function GetPath(ByVal prompt) | |
' Collect path. | |
path = InputBox(prompt) |