首页/ 接口索引/ 踩坑清单

HexValue 大小写不统一

统一 .upper() 再比较,否则筛颜色会漏。

现象

HexValue 大小写不统一

说明

统一 .upper() 再比较,否则筛颜色会漏。

Python 示例(可直接运行)

依赖 pywin32。示例假定 app / doc / page / layer 已就绪。 见「连接与初始化」
Python
shape = app.ActiveSelectionRange(1)

# HexValue 大小写不固定,比色前统一 upper()
hex_now = (shape.Fill.UniformColor.HexValue or "").upper()
YELLOW = "#FFFF00"

print("当前:", hex_now, " 是黄色:", hex_now == YELLOW)

关于本类:踩坑清单

都是会「不报错但结果不对」的坑,比抛异常更难查。

同类其他接口