mystring-tools-2131030295 0.1.0__tar.gz
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.
- mystring_tools_2131030295-0.1.0/LICENSE +0 -0
- mystring_tools_2131030295-0.1.0/PKG-INFO +14 -0
- mystring_tools_2131030295-0.1.0/README.md +3 -0
- mystring_tools_2131030295-0.1.0/mystring_tools/__init__.py +4 -0
- mystring_tools_2131030295-0.1.0/mystring_tools/core.py +51 -0
- mystring_tools_2131030295-0.1.0/mystring_tools_2131030295.egg-info/PKG-INFO +14 -0
- mystring_tools_2131030295-0.1.0/mystring_tools_2131030295.egg-info/SOURCES.txt +9 -0
- mystring_tools_2131030295-0.1.0/mystring_tools_2131030295.egg-info/dependency_links.txt +1 -0
- mystring_tools_2131030295-0.1.0/mystring_tools_2131030295.egg-info/top_level.txt +1 -0
- mystring_tools_2131030295-0.1.0/pyproject.toml +14 -0
- mystring_tools_2131030295-0.1.0/setup.cfg +4 -0
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mystring_tools_2131030295
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 一个简单的Python字符串处理工具包
|
|
5
|
+
Author-email: 你的名字 <你的邮箱@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# Mystring Tools
|
|
13
|
+
这是一个用于学习打包的字符串处理工具包。
|
|
14
|
+
包含统计单词数、反转字符串、判断回文、凯撒密码、词频统计等功能。
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
def count_words(text):
|
|
2
|
+
"""
|
|
3
|
+
统计字符串中的单词数量
|
|
4
|
+
"""
|
|
5
|
+
if not text:
|
|
6
|
+
return 0
|
|
7
|
+
# 以空格分割并过滤掉空字符串
|
|
8
|
+
words = text.split()
|
|
9
|
+
return len(words)
|
|
10
|
+
|
|
11
|
+
def reverse_string(text):
|
|
12
|
+
"""
|
|
13
|
+
反转字符串
|
|
14
|
+
"""
|
|
15
|
+
return text[::-1]
|
|
16
|
+
|
|
17
|
+
def is_palindrome(text):
|
|
18
|
+
"""
|
|
19
|
+
判断是否为回文串(忽略大小写和标点符号)
|
|
20
|
+
"""
|
|
21
|
+
import re
|
|
22
|
+
# 移除非字母数字字符并转为小写
|
|
23
|
+
clean_text = re.sub(r'[^a-zA-Z0-9]', '', text).lower()
|
|
24
|
+
return clean_text == clean_text[::-1]
|
|
25
|
+
|
|
26
|
+
def caesar_cipher(text, shift):
|
|
27
|
+
"""
|
|
28
|
+
凯撒密码加密/解密
|
|
29
|
+
"""
|
|
30
|
+
result = ""
|
|
31
|
+
for char in text:
|
|
32
|
+
if char.isalpha():
|
|
33
|
+
# 判断大小写并处理循环
|
|
34
|
+
base = ord('A') if char.isupper() else ord('a')
|
|
35
|
+
result += chr((ord(char) - base + shift) % 26 + base)
|
|
36
|
+
else:
|
|
37
|
+
result += char
|
|
38
|
+
return result
|
|
39
|
+
|
|
40
|
+
def word_frequency(text):
|
|
41
|
+
"""
|
|
42
|
+
统计词频,返回前三个高频词
|
|
43
|
+
"""
|
|
44
|
+
words = text.lower().split()
|
|
45
|
+
freq = {}
|
|
46
|
+
for word in words:
|
|
47
|
+
freq[word] = freq.get(word, 0) + 1
|
|
48
|
+
|
|
49
|
+
# 按频率降序排序并取前三
|
|
50
|
+
sorted_words = sorted(freq.items(), key=lambda x: x[1], reverse=True)
|
|
51
|
+
return sorted_words[:3]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mystring_tools_2131030295
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 一个简单的Python字符串处理工具包
|
|
5
|
+
Author-email: 你的名字 <你的邮箱@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# Mystring Tools
|
|
13
|
+
这是一个用于学习打包的字符串处理工具包。
|
|
14
|
+
包含统计单词数、反转字符串、判断回文、凯撒密码、词频统计等功能。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
mystring_tools/__init__.py
|
|
5
|
+
mystring_tools/core.py
|
|
6
|
+
mystring_tools_2131030295.egg-info/PKG-INFO
|
|
7
|
+
mystring_tools_2131030295.egg-info/SOURCES.txt
|
|
8
|
+
mystring_tools_2131030295.egg-info/dependency_links.txt
|
|
9
|
+
mystring_tools_2131030295.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mystring_tools
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mystring_tools_2131030295" # 这里加上你的学号防重名
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "一个简单的Python字符串处理工具包"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "你的名字", email = "你的邮箱@example.com"}
|
|
14
|
+
]
|