資訊之芽 2023 Python 語法班
Author: Sean 韋詠祥
未來展望?
基本 Bash 指令
cd example # 進入資料夾
cd .. # 回到前一層目錄
cd # 不加參數,代表回到家目錄
pwd # 顯示當前目錄
ls # 列出目前目錄下的檔案
ls -l # 顯示詳細資訊
ls -a # 包含隱藏檔案
ls -al # 我全都要!
cat slides.md # 印出檔案內容
less /etc/passwd # 慢慢查看檔案內容
echo Hello
echo Hello World
echo Hello World
echo "Hello World"
echo "Hey there" > myfile
echo "Hey there" >> myfile
touch myfile # 建立空檔案
mkdir mycode # 建立資料夾
mv myfile file1 # 移動檔案
cp file1 file2 # 複製檔案
rm file1 # 刪除檔案
rmdir mycode # 刪除空資料夾
Git 核心邏輯
使用 Git 擴充套件
驗證碼:選出相同物品
可點擊下方 Skip 跳過
抓取程式碼、安裝環境
使用 git clone 指令
git clone https://github.com/Sean-Py2023/dc-bot.git
cd dc-bot
ls
已安裝 python3.11 及 pip 程式
請自行安裝需要的 pip 套件
pip install discord
pip install python-dotenv
pip install ....
跟筆電上方式類似
python3 bot.py
記得把 .env
也帶過去
nano .env # 編輯檔案
Continuous Integration
Continuous Delivery
Continuous Deployment
持續整合
持續交付
持續部署
由 GitHub 提供的 CI/CD 服務
ssh-keygen -t ed25519
cat .ssh/id_ed25519.pub >> .ssh/authorized_keys
補充教材
Git Repository
cd ~
mkdir my-project # 建立資料夾
cd my-project
git init # 初始化 git
touch main.py # 建立 main.py 或 main.cpp 檔案
git add main.py # 把檔案從 working area 加入 staging area
git commit
# 在編輯器中輸入 commit 訊息:init
# 完成!
先用編輯器打開 main.py
檔案
nano main.py
用 for
跟 range()
讓他輸出 0 到 4 這五個數字,每次換行
完成後用 git 保存版本紀錄
git status # 有誰被改到了
git add main.py
git commit
輸入:一個正整數 N
輸出:從 0 到 N-1 的數字,每次換行
git diff # 我們改了什麼
git add -p main.py
git commit
Hint:用 int(input())
接收輸入
輸入:一個正整數 N
輸出:從 1 到 N 的數字,每次換行
git add -p .
git commit -m '<commit message>'
試著查看歷史紀錄
git show # 預設為 HEAD
git show HEAD~1 # 往前 1 筆
試試這個指令吧
git log
幫大家設定好更漂亮的版本了:
git lg