嗨,我想从 html 表单获取输入并将其传递给我的 python 脚本并使其执行,然后我想在不使用任何框架的情况下在浏览器中打印我的结果。下面是我的python代码:
import re
hap=['amused','beaming','blissful','blithe','cheerful','cheery','delighted']
sad=['upset','out','sorry','not in mood','down']
sad_count=0
happy_count=0
str1=raw_input("Enter Message...\n")
happy_count=len(filter(lambda x:x in str1,hap))
sad_count=len(filter(lambda x:x in str1,sad))
if(happy_count>sad_count):
print("Hey buddy...your mood is HAPPY :-)")
elif(sad_count>happy_count):
print("Ouch! Your Mood is Sad :-(")
elif(happy_count==sad_count):
if(happy_count>0 and sad_count>0):
print("oops! You are in CONFUSED mood :o")
else:
print("Sorry,No mood found :>")