一种套管与另一种套管之间的变化
change_case的Python项目详细描述
更改大小写
这是干什么的?
尽管很简单,但我很惊讶在pypi中没有库能够完全处理从一个 另一种风格。当然很简单。title()很简单。但是这个库允许您轻松地获取任何类型的外壳 一对一。
支持的类型
- camelCase(下驼峰形外壳)
- PascalCase(上驼壳)
- WikiCase
- snake_case
- 参数大小写(用于URL)
python版本支持
我只计划支持python 3,因为这是我主要使用的。它在Python3.3+上工作。我没试过 旧版本。
使用量
更换箱子很容易使用。您只需传递一个字符串来获取新值。例如,如果要转换 camelCasedString到snake_cased_string,您只需运行:
old = "camelCasedString" new = ChangeCase.camel_to_snake(old) print(new) # camel_cased_string
要查看可能的内容,只需查看主文件。可以通过直接运行文件来运行测试。你也可以看看 测试以查看每个测试的用法和响应。
测试
您可以通过两种方法之一轻松运行测试。您可以使用python手动运行change_case.py文件,它将运行 测试。
python3 change_case.py
或者您也可以这样做:
In [1]: from change_case import ChangeCase In [2]: ChangeCase.run_tests() camel_to_upper_camel tests passed. camel_to_pascal tests passed. camel_to_wiki tests passed. camel_to_snake tests passed. camel_to_param tests passed. pascal_to_camel tests passed. pascal_to_upper_camel tests passed. pascal_to_wiki tests passed. pascal_to_snake tests passed. pascal_to_param tests passed. wiki_to_camel tests passed. wiki_to_upper_camel tests passed. wiki_to_pascal tests passed. wiki_to_snake tests passed. wiki_to_param tests passed. snake_to_camel tests passed. snake_to_upper_camel tests passed. snake_to_pascal tests passed. snake_to_wiki tests passed. snake_to_param tests passed. param_to_camel tests passed. param_to_upper_camel tests passed. param_to_pascal tests passed. param_to_wiki tests passed. param_to_snake tests passed.
贡献和错误
您可以在此处提交任何问题:
https://github.com/SkiftCreative/python-change-case/issues
添加新的案例类型相当简单。只需将方法添加到ChangeCase并将测试添加到 ChangeCase.run_tests()
许可证
麻省理工学院许可证(MIT)
版权所有(C)[2015][Shawn McElroy]
兹免费准许任何人取得副本 本软件和相关文档文件(“软件”)的 在软件中不受限制,包括但不限于 使用、复制、修改、合并、发布、分发、再授权和/或出售 软件的副本,并允许软件的用户 在满足以下条件的情况下,可以这样做:
上述版权公告及本许可公告须包括在 软件的拷贝或大部分。
本软件按“原样”提供,无任何形式的保证,明示或 默示的,包括但不限于适销性保证, 适合特定目的和不侵权。在任何情况下 作者或版权所有者应对任何索赔、损害或其他 责任,无论是在合同诉讼、侵权诉讼或其他诉讼中, 不属于或与本软件有关,或使用或与本软件的其他交易有关。 软件。