💡 快捷工具:本 skill 包含辅助脚本和参考文档
- Python 脚本:
scripts/weather.py- 多功能天气查询工具(统一使用)- 参考指南:
references/quick-reference.md- 速查手册
wttr.in 是一个功能强大的基于控制台天气预报服务,支持多种输出格式和全球位置查询。
bash
# 当前位置(基于 IP)
python scripts/weather.py
# 指定城市
python scripts/weather.py Beijing
python scripts/weather.py Shanghai
python scripts/weather.py "New+York"
python scripts/weather.py London
# 使用 ~ 查询特殊地点(景点、山脉等)
python scripts/weather.py "~Eiffel+Tower"
python scripts/weather.py "~Mount+Everest"
# 机场代码查询
python scripts/weather.py PEX # 北京首都机场
python scripts/weather.py PVG # 上海浦东机场
python scripts/weather.py LAX # 洛杉矶机场
bash
# 公制单位(摄氏度,默认除美国外)
python scripts/weather.py Beijing -u m
# 英制单位(华氏度)
python scripts/weather.py Beijing -u u
# 公制 + m/s 风速
python scripts/weather.py Beijing -u M
bash
# 标准输出(自动检测)
python scripts/weather.py Beijing
# 强制纯文本(无颜色)
python scripts/weather.py Beijing -f plain
# 限制为标准控制台字符
python scripts/weather.py Beijing -f compact
bash
# 下载 PNG 天气图
python scripts/weather.py Beijing -f png -o weather.png
# 透明背景
python scripts/weather.py Beijing -f png --transparent -o weather.png
# 自定义透明度 (0-255)
python scripts/weather.py Beijing -f png --transparent --transparency 150
bash
# 完整 JSON 数据
python scripts/weather.py Beijing -f json
# 精简 JSON(不含小时数据)
python scripts/weather.py Beijing -f json-lite
JSON 输出包含:
current_condition: 当前天气状况weather: 天气预报数据astronomy: 天文信息(日出、日落、月相)bash
# Prometheus 格式
python scripts/weather.py Beijing -f prometheus
适合集成到 tmux、weechat、状态栏等。
bash
# 格式 1: 当前天气
python scripts/weather.py Beijing -f oneline --custom-format "1"
# 🌦 +11⁰C
# 格式 2: 详细信息
python scripts/weather.py Beijing -f oneline --custom-format "2"
# 🌦 🌡️+11°C 🌬️↓4km/h
# 格式 3: 位置 + 天气
python scripts/weather.py Beijing -f oneline --custom-format "3"
# Beijing: 🌦 +11⁰C
# 格式 4: 完整信息
python scripts/weather.py Beijing -f oneline --custom-format "4"
# Beijing: 🌦 🌡️+11°C 🌬️↓4km/h
代码含义代码含义%c天气状况图标%C天气状况文本%x天气符号(纯文本)%h湿度%t实际温度%f体感温度%w风速和方向%l位置名称%m月相 🌑🌒🌓🌔🌕🌖🌗🌘%M月龄%p降水量 (mm/3h)%P气压 (hPa)%uUV 指数 (1-12)%D黎明时间*%S日出时间*%z天顶时间*%s日落时间*%d黄昏时间*%T当前时间*%Z本地时区
*时间以本地时区显示
bash
# 自定义输出示例
python scripts/weather.py Beijing --custom-format "%l:+%c+%t+%h+%w\n"
# Beijing: ⛅️ +7°C 45% ↓12km/h
# 多地点查询
python scripts/weather.py "Beijing:Shanghai:Guangzhou" -f oneline --custom-format "3"
实验性功能,提供详细天气和天文信息。
bash
# 使用 v2 格式
python scripts/weather.py Beijing -f v2
# 使用 Nerd Fonts(日间模式)
python scripts/weather.py Beijing -f v2-day
# 使用 Nerd Fonts(夜间模式)
python scripts/weather.py Beijing -f v2-night
包含信息:
显示地理区域的天气信息。
bash
# PNG 格式(浏览器)
python scripts/weather.py California -f v3
# Sixel 格式(支持内联图像的终端)
python scripts/weather.py Bayern -f v3
bash
# 当前位置月相
python scripts/weather.py -f moon
# 指定日期
python scripts/weather.py -f moon --moon-date 2025-12-25
# 作为天气查询的一部分
python scripts/weather.py Beijing --custom-format "%m"
# 🌖
bash
# 通过语言参数设置
python scripts/weather.py Beijing -l zh
python scripts/weather.py Paris -l fr
python scripts/weather.py Berlin -l de
python scripts/weather.py Tokyo -l ja
# 查询非英文名称位置
python scripts/weather.py "станция+Восток"
python scripts/weather.py "~长城"
支持 54+ 种语言,包括:zh(中文)、en(英语)、fr(法语)、de(德语)、ru(俄语)、ja(日语)等。
tmux
# ~/.tmux.conf
set -g status-interval 60
# 使用 Python 脚本查询天气
WEATHER='#(python /path/to/weather.py Beijing -f oneline --custom-format "%%l:+%%c+%%t&period=60")'
set -g status-right "$WEATHER | %Y-%m-%d %H:%M"
bash
# ~/.bashrc 或 ~/.zshrc
alias weather='python /path/to/weather.py'
alias weather-json='python /path/to/weather.py -f json'
python
from weather import WeatherQuery
weather = WeatherQuery("Beijing")
# 获取 JSON 数据
data = weather.json_full()
print(f"当前温度:{data['current_condition'][0]['temp_C']}°C")
# 获取一行输出
print(weather.oneline("3"))
: 分隔,配合 period 参数format=j1) 便于解析Emoji 显示问题:
fc-cache -f -v 刷新字体缓存终端不支持:
?T 参数强制纯文本?d 限制为标准字符端点用途wttr.in标准天气预报v2.wttr.in数据丰富格式v3.wttr.in地图视图
参数说明?m公制单位?u英制单位?M公制 + m/s?T纯文本?d限制字符?format=X输出格式?lang=XX语言代码period=N更新周期(秒)
代码描述113晴朗/少云116局部多云119多云122阴天176/263/266/293/296/299/302/305/308/353/356/359/386/389各种降雨/雷暴179/311/314/317/320/323/326/329/332/335/338/350/377各种降雪/冰雹143/182/248/260雾/霾
当用户需要查询天气时:
scripts/weather.py)#功能丰富的查询工具,支持多种输出格式:
bash
# 标准天气查询
python scripts/weather.py Beijing
# JSON 格式(适合程序处理)
python scripts/weather.py Beijing -f json
# 精简 JSON(不含小时数据)
python scripts/weather.py Beijing -f json-lite
# 一行输出(适合状态栏)
python scripts/weather.py Beijing -f oneline
# 自定义格式
python scripts/weather.py Tokyo --custom-format "%l: %c %t"
# 下载 PNG 图片
python scripts/weather.py Paris -f png -o weather.png
# 详细预报 (v2)
python scripts/weather.py Beijing -f v2
# 地图视图 (v3)
python scripts/weather.py California -f v3
# 月相查询
python scripts/weather.py -f moon
# 指定日期月相
python scripts/weather.py -f moon --moon-date 2025-12-25
参数说明location地点名称(可选,默认为当前位置)-f, --format输出格式:terminal, json, json-lite, oneline, png, v2, v2-day, v2-night, v3, plain, compact, prometheus, moon-l, --lang语言代码(默认 zh)-u, --unit单位:m=公制,u=英制,M=公制+m/s-o, --output输出文件路径(PNG 格式用)--custom-format自定义 format 参数(%-notation)--moon-date月相查询日期 (YYYY-MM-DD)--transparentPNG 透明背景--transparencyPNG 透明度 (0-255)
references/quick-reference.md)#速查手册,包含:
建议:查询具体参数或忘记语法时,参考 references/quick-reference.md