vendredi 25 octobre 2019

Comparing two word if they are a like or not, python

I using Tkinter in python and I have a optionmenu wich contains set of elements:

Customer Workshop SupplyChain

Then I have a textfile called "RestRout3.txt" which contains a long list:

Supplychain/dealer/etc.
Supplychain/parts/etc.
Supplychain/shop/etc.
Supplychain/order/etc.
Supplychain/tasks/etc.
Supplychain/payment/etc.
Workshop/location/etc.
Workshop/name/etc.
Workshop/report/etc.
Customer/info/etc.
Customer/order/etc.

In my application I have button, when clicked it will run this method def Action(): By doing some if-statements, I want to get both of the same word to be matching.

def Action():
    appName = variabel.get() #Element selected from Optionmenu

    with open("RestRout3.txt", "r") as f:
        content = f.readlines()
        print (content) # reads all the content in file
    return content
    if appName == content[0]: # for example appname(supplychain) and content(supplychain)
        print ("Both words are matching")

I expect the both words to be matching, so I can do more function later.

I appreciate all help I can get, thanks. I'm new to python.

Aucun commentaire:

Enregistrer un commentaire