したがって、次の2つのスクリプトがあります。
スクリプト 1:
while True:
userInput = raw_input(">>> ")
if userInput.lower() in ["yo",'hi', 'hello', 'hi there', 'hey there']:
print "Hi, I'm Jane."
elif userInput.lower() in ["sup", "what's up", "how are you", "how are u", "sup?", "what's up?", "how are you?", "how are u?"]:
whassup = ['Not much, you?','The usual!', 'Working on paperwork.', 'Helping out, haha.', 'Annoying my sisters.']
print(random.choice(whassup))
elif userInput.lower() in ["cool", "awesome", "sounds cool", "rad"]:
print "Aww, thanks!"
else:
print "Sorry, I can only use SpeedChat."
次に、スクリプト 2 を次に示します。これは、 hereのサンプル コードを少し編集したバージョンです。
#add some text
bk_text = "This is my Demo"
userin = OnscreenText(text = bk_text, pos = (0, 0.7),
scale = 0.07,fg=(0,0,0,1),align=TextNode.ACenter,mayChange=1)
userin.setFont(font)
#callback function to set text
def setText(textEntered):
userin.setText(textEntered)
#clear the text
def clearText():
b.enterText('')
#add button
b = DirectEntry(text = "" ,scale=.05, command=setText,
initialText="Type Something", numLines = 2,focus=1,focusInCommand=clearText)
以下のようなので。私がしようとしているのは、ユーザーが入力を DirectEntry ボックスに入力して、Panda3D パネル (アニメ化されたキャラクターがありますが、それは関係ありません) がプログラムの応答を出力するようにすることです。
つまり、ユーザーは「Hello!」と入力します。そのため、プログラムは「こんにちは、私はジェーンです」と吐き出します。画面上。
私はコーディングが初めてで、文字通り、私がやることはすべて非常に複雑です。少し説明すると非常に役立ちます!! どうもありがとう!