万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    Python

    一番最新ファイル

    # 最新画像を1枚取り出す
    def find_latest_file_with_number(filenames, search_number):
        """
        This function finds the file with the largest numerical part in its name, given a specific number in the pattern.
        """
        # Compile a regular expression to match the pattern (including the specific number) and extract the numerical part
        regex = re.compile(rf"img_{search_number}_(\d+)\.jpg")
    
        # Dictionary to hold the files and their numerical parts
        file_dict = {}
    
        # Extract the numerical part for each file that matches the pattern
        for filename in filenames:
            match = regex.match(filename)
            if match:
                file_dict[filename] = int(match.group(1))
    
        # Find the file with the largest numerical part
        if file_dict:
            return max(file_dict, key=file_dict.get)
        else:
            return None