auto-tools-isee 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
auto_tools/__init__.py
ADDED
auto_tools/core.py
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
def reverse_string(s: str) -> str:
|
2
|
+
"""
|
3
|
+
反转字符串
|
4
|
+
|
5
|
+
参数:
|
6
|
+
s (str): 需要反转的字符串
|
7
|
+
|
8
|
+
返回:
|
9
|
+
str: 反转后的字符串
|
10
|
+
|
11
|
+
异常:
|
12
|
+
TypeError: 如果输入不是字符串类型,则抛出此异常
|
13
|
+
"""
|
14
|
+
# 类型检查
|
15
|
+
if not isinstance(s, str):
|
16
|
+
raise TypeError("输入必须是字符串类型")
|
17
|
+
|
18
|
+
# 字符串反转逻辑
|
19
|
+
try:
|
20
|
+
return s[::-1]
|
21
|
+
except Exception as e:
|
22
|
+
# 捕获潜在的异常并提供更友好的错误信息
|
23
|
+
raise RuntimeError(f"字符串反转时发生错误: {e}")
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
def count_vowels(s: str) -> int:
|
28
|
+
"""
|
29
|
+
统计字符串中元音字母的数量。
|
30
|
+
|
31
|
+
参数:
|
32
|
+
s (str): 输入字符串。
|
33
|
+
|
34
|
+
返回:
|
35
|
+
int: 元音字母的数量。
|
36
|
+
|
37
|
+
注意:
|
38
|
+
如果输入不是字符串类型,将抛出 ValueError。
|
39
|
+
"""
|
40
|
+
# 定义元音字母集合,提升查找效率
|
41
|
+
VOWELS = set('aeiouAEIOU')
|
42
|
+
|
43
|
+
# 输入验证,确保输入是字符串类型
|
44
|
+
if not isinstance(s, str):
|
45
|
+
raise ValueError("输入必须是字符串类型")
|
46
|
+
|
47
|
+
# 使用生成器表达式统计元音字母数量
|
48
|
+
return sum(1 for char in s if char in VOWELS)
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
def is_palindrome(s: str) -> bool:
|
53
|
+
"""
|
54
|
+
判断给定字符串是否为回文字符串。
|
55
|
+
|
56
|
+
参数:
|
57
|
+
s (str): 输入字符串,可以包含空格和标点符号。
|
58
|
+
|
59
|
+
返回:
|
60
|
+
bool: 如果字符串是回文,则返回 True;否则返回 False。
|
61
|
+
|
62
|
+
注意:
|
63
|
+
1. 忽略大小写。
|
64
|
+
2. 忽略空格和标点符号。
|
65
|
+
3. 空字符串被视为回文。
|
66
|
+
"""
|
67
|
+
if not isinstance(s, str):
|
68
|
+
raise ValueError("输入必须是字符串类型")
|
69
|
+
|
70
|
+
# 过滤掉非字母数字字符,并转换为小写
|
71
|
+
cleaned = ''.join(c.lower() for c in s if c.isalnum())
|
72
|
+
|
73
|
+
# 使用双指针法判断回文
|
74
|
+
left, right = 0, len(cleaned) - 1
|
75
|
+
while left < right:
|
76
|
+
if cleaned[left] != cleaned[right]:
|
77
|
+
return False
|
78
|
+
left += 1
|
79
|
+
right -= 1
|
80
|
+
return True
|
81
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: auto_tools_isee
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Advanced string manipulation utilities
|
5
|
+
Home-page:
|
6
|
+
Author: ISEE
|
7
|
+
Author-email: your.email@example.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.9
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
Requires-Dist: requests>=2.32.3
|
14
|
+
Provides-Extra: dev
|
15
|
+
Requires-Dist: requests>=2.32.3; extra == "dev"
|
16
|
+
Dynamic: author
|
17
|
+
Dynamic: author-email
|
18
|
+
Dynamic: classifier
|
19
|
+
Dynamic: description-content-type
|
20
|
+
Dynamic: provides-extra
|
21
|
+
Dynamic: requires-dist
|
22
|
+
Dynamic: requires-python
|
23
|
+
Dynamic: summary
|
@@ -0,0 +1,7 @@
|
|
1
|
+
auto_tools/__init__.py,sha256=w-9iifqe2SnnFB9u0iV5uqLSPI9B1BlzH63cLVTfx4Y,146
|
2
|
+
auto_tools/core.py,sha256=MTncIAXYQHqTOmQJNHA4Pp3Q5q63KGxay2Zo8aQT82s,2125
|
3
|
+
auto_tools_isee-0.1.0.dist-info/METADATA,sha256=ngCeBZzwQEGAjrARw03EVq23ih5iHY7F6xyLuwNujJ0,682
|
4
|
+
auto_tools_isee-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
5
|
+
auto_tools_isee-0.1.0.dist-info/entry_points.txt,sha256=e0DaRSOf9qm1ay_OGpgfNHsrPpowg_fAAdMhEpsvuDg,48
|
6
|
+
auto_tools_isee-0.1.0.dist-info/top_level.txt,sha256=XosaJ4UllPTyndmkL3me_4XRyURsU-wFqNzzvp5p0Tg,11
|
7
|
+
auto_tools_isee-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
auto_tools
|