请你用Python写一个可以自由对话的AL
时间: 2023-05-17 17:06:21 浏览: 72
好的,下面是一个使用 Python 实现的简单自由对话的 AI 程序的示例:
```python
import random
greetings = ['你好', 'hello', 'hi', 'Hi', 'hey!','hey']
random_greeting = random.choice(greetings)
print(random_greeting)
name = input('What is your name? ')
print('It is nice to meet you, ' + name)
mood = input('How are you feeling today? ')
print('I am glad that you are feeling ' + mood)
activity = input('What would you like to do today? ')
print('That sounds like a fun plan, ' + activity + ' sounds like a great way to spend the day')
```
在这个程序中,我们定义了一个叫做 `greetings` 的列表,其中包含了几个问候语。然后使用了 Python 的 `random` 模块中的 `choice` 函数来随机选择一个问候语,并使用 `print` 函数将其输出到屏幕上。然后使用了 `input` 函数来获取用户的输入,并使用 `print` 函数来输出对话信息。
这只是一个简单的例子,您可以根据需要自由添加更多的对话内容和功能。希望这对您有帮助!