[Python] Is there a way to compare two strings for likeness?

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have an issue where i need to link certain sample names to eachother, the problem however is that the sample names which i want to match are a little bit different from the keys in a dictionairy i have from which i need to get the correct value.

    example:

    sample = "foo_foo.bar.12"
    matching_dict = {"foo_foo-bar-12" : "foo.bar.12"}


    I have about 5500 samples, each with a different type of arrangement, so not every sample looks like the example i gave. Ideally i want a dynamic way of comparing the 2 strings with eachother and then get the value from the dict if they are most alike.

    Thank in advance!

    Continue reading...

Compartilhe esta Página