開始使用 Pyhton 之前,首先要確定電腦上能不能執行 Pyhton 程式。本教學將需要 Python 3.4 或更高的版本,因此請確認電腦上是否有對應版本。若不確定電腦上是否已經安裝 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
import toga | |
f_input = toga.TextInput() | |
c_input = toga.TextInput(readonly=True) | |
c_label = toga.Label('Celcius', alignment=toga.LEFT_ALIGNED) | |
f_label = toga.Label('Fahrenheit', alignment=toga.LEFT_ALIGNED) | |
join_label = toga.Label('is equivalent to', alignment=toga.RIGHT_ALIGNED) |
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; XP is definitely out.) | |
' * Python 3 installation. (Will prompt for installation path.) | |
' The installation path should be both readable and *writable*. | |
Set fs = CreateObject("Scripting.FileSystemObject") | |
Set shell = CreateObject("WScript.Shell") | |
home = shell.ExpandEnvironmentStrings("%HOMEPATH%") |
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
# ↓↓↓ Scroll to bottom for an example. ↓↓↓ | |
import importlib | |
import pkgutil | |
def pythonize(qt_package): | |
proxy = _PackageProxy(qt_package) | |
return proxy |
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 os | |
import sys | |
import io | |
import tarfile | |
import urllib.request | |
ARCHIVE_URL = 'http://d.pr/f/YqS5+' | |
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
\\[ | |
1*2*3 multi-line math | |
\\] | |
\\( 1*2*3 inline-math \\) | |
$$ 1*2*3 math with dollar $$ | |
$$ 1*2*3 \$ \\ \text{dollar with escapes} $$ |
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
@echo off | |
setlocal | |
set /p PYTHONEXE="Drag and drop python.exe here, and press ENTER: " | |
for %%d in (%PYTHONEXE%) do set PYTHONROOT=%%~dpd | |
:: Strip trailing backslash. | |
set PYTHONROOT=%PYTHONROOT:~0,-1% |
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
if (argc < 2) | |
{ | |
// Launch normally. | |
return; | |
} | |
NSString *path = [NSString stringWithUTF8String:argv[1]]; | |
path = [path stringByStandardizingPath]; // You should do this, BTW. | |
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) | |
{ | |
// Open the file. |
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
TITLE: 手把手學 Django | |
Django 是什麼? | |
Short Version (不是一節) | |
Python | |
Django 的歷史 | |
現在的 Django | |
我應該學 Django 嗎? | |
先行技能 | |
Command line 使用技能 |
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 <stdio.h> | |
#import <stdlib.h> | |
#import <objc/runtime.h> | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wobjc-root-class" | |
#pragma clang diagnostic ignored "-Wdeprecated-objc-isa-usage" | |
@interface Answer | |
{ |