跳到主要内容
uencoder

Snake Case

Snake case 用下划线连接小写单词(如 user_name),常用于 Python、数据库列名与 JSON。

用途

提供可读的多词标识符命名风格,适合不区分大小写的环境。

机制

将单词转为小写并用下划线连接。如 "UserName" → "user_name"。Python、Ruby、SQL、C 函数名常用。与 kebab-case(短横线)类似但用下划线。

用例

  • Python 变量与函数名
  • 数据库列名
  • JSON 键名
  • C/Rust 函数名

示例

  • 输入
    UserName
    输出
    user_name

    Joined with underscores

常见错误

Mixing with kebab-case causes inconsistent style
Standardize the naming style across the project

相关词条

相关工具

参考链接