Python define a word?

前端 未结 2 1137
无人共我
无人共我 2021-01-29 11:51

Can I use python to define a word like this:

x=raw_input(\"Enter Word: \")
x=define(x)
print x

Is this possible? If si.. how 2 do it?

T

2条回答
  •  没有蜡笔的小新
    2021-01-29 12:25

    You can probobally do this using the re and urllib2 modules.. Try this code out dawg.

    import re
    import urllib2
    def find(x):
        srch=str(x)
        x=urllib2.urlopen("http://dictionary.reference.com/browse/"+srch+"?s=t")
        x=x.read()
        items=re.findall('','')
            m=re.findall('at Dictionary.com, a free online dictionary with pronunciation,              synonyms and translation. Look it up now! "/>',z)
            if m==[]:
                if z.startswith("Get your reference question answered by Ask.com"):
                    print "Word not found! :("
                else:
                    print z
        else:
                print "Word not found! :("
    x=raw_input("Enter word to find: ")
    find(x)
    

    Let me know how it goes!

提交回复
热议问题