str.isdigit

str.isdigit(...)

Description

Documentation for str.isdigit.

Python Python String Methods Official Docs

Real-World Examples

Practical code examples showing how str.isdigit is used in real projects.

language = self._extract_tag(extracted_responses[self.BASIC_QUERY_INDEX], "language")

            # 提取最低星标数
            min_stars = 0
            min_stars_text = self._extract_tag(extracted_responses[self.BASIC_QUERY_INDEX], "min_stars")
            if min_stars_text and min_stars_text.isdigit():
                min_stars = int(min_stars_text)

            # 解析GitHub搜索参数 - 英文
            english_github_query = self._extract_tag(extracted_responses[self.GITHUB_QUERY_INDEX], "query")

            # 解析GitHub搜索参数 - 中文
            chinese_github_query = self._extract_tag(extracted_responses[2], "query")

            # 构建GitHub参数
            github_params = {
                "query": english_github_query,
                "chinese_query": chinese_github_query,
                "sort": "stars",  # 默认按星标排序
                "order": "desc",  # 默认降序
                "per_page": 30,   # 默认每页30条
                "page": 1         # 默认第1页
            }

            # 检查是否为特定仓库查询
# Remove leading/trailing hyphens
        name = name.strip("-")

        # Additional validation to ensure meaningful names
        # Check if name contains only numbers or is too short
        if not name or name.isdigit() or len(name) < 3:
            name = "monsterrr-project"
        # Check if name is too generic
        elif name in ["project", "app", "application", "software", "tool", "program", "demo", "test", "example"]:
            name = f"monsterrr-{name}"
        # Ensure name is descriptive enough
        elif len(name) < 6 and "-" not in name:
            name = f"monsterrr-{name}-tool"
        # Check for meaningless combinations
        elif re.match(r"^[a-z]{3,6}-[a-z]{3,6}$", name) and not any(keyword in name for keyword in [
            "api", "bot", "cli", "web", "data", "code", "dev", "auto", "smart", "ml", "ai", "cloud", "iot", "sec", "u...
        ]):
            # If it's a generic two-word combination, make it more specific
            name = f"{name}-utility"

        # Ensure name is not empty and not too long
        if not name:
            name = "monsterrr-project"
        elif len(name) > 50:
            name = name[:50].rstrip("-")