众所周知,人工智能是未来的趋势
作为一个牛X的程序员,当然得 蹭蹭热度
那……就展示一下我在编程课上学到的智能语音机器人吧
算了,再附送一个《完整》的QQ代码吧!
(前提是你关注了我)
不
怎
么
华
丽
的
分
隔
线
好了,现在你……应该点了关注了吧
那我们继续↓
我们一段一段解析:
import requests
import easygui
import time
import random
这里就是导入库↑
API_KEY="XXX"
API_SECRET="XXX"
easygui.msgbox("欢迎来到木子的QQ!","木子的QQ","愉快地进入","1.gif")#记得要放个1.gif
person=None
先初始化爬虫语音助手的账号,再做个启动页面↑
while 1:
from easygui import*
password=multpasswordbox(msg="请输入账号及密码"+chr(10)+"(区分大小写)",title="木子的QQ",fields=["用户名","密码"],values=["admin","123456789"])
if password[0]=="123"or"456"or"789":#验证账号
if password[1]=="XXXXX": #验证密码
if password[0]=="1234567890":#验证身份(1)
easygui.msgbox("欢迎您,XX!","木子的QQ","进入QQ")
person="XX"
break
elif password[0]=="1234567890":#验证身份(2)
easygui.msgbox("欢迎您,XX!","木子的QQ","进入QQ")
person="XX"
break
elif password[0]=="1234567890":#验证身份(3)
easygui.msgbox("欢迎您,开发者!","木子的QQ","进入QQ")
person="XX"
break
else:
easygui.msgbox("账号或密码错误(a02)","木子的QQ")#密码错误
else:
easygui.msgbox("账号或密码错误(a01)","木子的QQ")#账号错误
做一个登录的GUI界面↑
easygui.msgbox("正在进入QQ......","木子的QQ","LOADING...")
time.sleep(random.randint(0, 3))
easygui.msgbox("成功进入QQ!","木子的QQ","进入")
loop()
然后做一个正在进入的界面,再运行“loop”(即主页界面)↑
def loop():#重复QQ窗口
age=easygui.choicebox("“XX”的好友列表"+chr(10)+"昵称:无聊的木子",choices=["家人","同学","路人","智能机器人"])#进入目录
if age=="家人":
family()
elif age=="同学":
classmate()
elif age=="路人":
passerby()
elif age=="智能机器人":
robot()
else:
easygui.msgbox("拜拜了"+chr(10)+"(;´༎ຶД༎ຶ`)","木子的QQ","离开")
exit()
然后是主界面(选择聊天)↑
def family():#进入“家庭”的目录
a=easygui.choicebox("“家人”中的目录",choices=["爸爸","妈妈","无聊的木子","EXIT"])
if a=="EXIT":
loop()
elif a=="爸爸"or a=="妈妈"or a=="无聊的木子":
chat=""
newchat=easygui.textbox("(聊天记录已清空)","和"+a+"的聊天")
while True:
if newchat:
chat=chat+"\n"+person+":"+newchat
newchat=easygui.textbox(chat,"和"+a+"的聊天")
else:
loop()
else:
loop()
def classmate():#进入“同学”的目录
a=easygui.choicebox("“同学”中的目录",choices=["张三","李四","王二麻子","EXIT"])
if a=="EXIT":
loop()
elif a=="张三"or a=="李四"or a=="王二麻子":
chat=""
newchat=easygui.textbox("(聊天记录已清空)","和"+a+"的聊天")
while True:
if newchat:
chat=chat+"\n"+person+":"+newchat
newchat=easygui.textbox(chat,"和"+a+"的聊天")
else:
loop()
else:
loop()
def passerby():#进入“路人”的目录
a=easygui.choicebox("“路人”中的目录",choices=["路人甲","路人乙","路过的机器人(智能AI)","EXIT"])
if a=="EXIT":
loop()
elif a=="路人甲"or a=="路人乙":
chat=""
newchat=easygui.textbox("(聊天记录已清空)","和"+a+"的聊天")
while True:
if newchat:
chat=chat+"\n"+person+":"+newchat
newchat=easygui.textbox(chat,"和"+a+"的聊天")
else:
loop()
else:
loop()
这里就是一些简单的聊天窗口↑
最重要的来了——
他来了他来了……
就是爬虫聊天机器人(图灵机器人)
def robot():
easygui.msgbox("Remember:please keep the network connected."+chr(10)+"Otherwise, the voice assistant can't be used","木子的QQ","network is OK")
newchat=" "
chat="(聊天记录已清空)"
API_KEY=""#记得填啊,你以为我会给你吗
API_SECRET=""
while True:
if newchat:
url=('http://i.itpk.cn/api.php?question='+newchat+"&api_key="+API_KEY+"&api_secret="+API_SECRET)
file=requests.get(url)#获取网页代码文件
data=file.text#把代码转换成文字
chat=chat+"\n"+person+":"+newchat+"\n"+"机器人:"+data#说话
else:
loop()
newchat=easygui.textbox(chat,"和智能机器人的聊天")
这一段可是
混沌未分天地乱,茫茫渺渺无人见。
自从盘古破鸿蒙,开辟从兹清浊辨。
覆载群生仰至仁,发明万物皆成善。
欲知造化会元功,须看西游释厄传。
…………………………
哈哈也不是啦,就是简单的爬虫而已嘛
但是你要给我点赞转发加关注
源码如下:(我可是贡献了自己的最大力量了,给个评论不过分吧)
def robot():
easygui.msgbox("Remember:please keep the network connected."+chr(10)+"Otherwise, the voice assistant can't be used","木子的QQ","network is OK")
newchat=" "
chat="(聊天记录已清空)"
API_KEY=""
API_SECRET=""#不填就会报错
while True:
if newchat:
url=('http://i.itpk.cn/api.php?question='+newchat+"&api_key="+API_KEY+"&api_secret="+API_SECRET)
file=requests.get(url)#获取网页代码文件
data=file.text#把代码转换成文字
chat=chat+"\n"+person+":"+newchat+"\n"+"机器人:"+data#说话
else:
loop()
newchat=easygui.textbox(chat,"和智能机器人的聊天")
def family():#进入“家庭”的目录
a=easygui.choicebox("“家人”中的目录",choices=["爸爸","妈妈","弟弟","EXIT"])
if a=="EXIT":
loop()
elif a=="XX"or a=="XX"or a=="XX":
chat=""
newchat=easygui.textbox("(聊天记录已清空)","和"+a+"的聊天")
while True:
if newchat:
chat=chat+"\n"+person+":"+newchat
newchat=easygui.textbox(chat,"和"+a+"的聊天")
else:
loop()
else:
loop()
def classmate():#进入“同学”的目录
a=easygui.choicebox("“同学”中的目录",choices=["张三","李四","王二麻子","EXIT"])
if a=="EXIT":
loop()
elif a=="张三"or a=="李四"or a=="王二麻子":
chat=""
newchat=easygui.textbox("(聊天记录已清空)","和"+a+"的聊天")
while True:
if newchat:
chat=chat+"\n"+person+":"+newchat
newchat=easygui.textbox(chat,"和"+a+"的聊天")
else:
loop()
else:
loop()
def passerby():#进入“路人”的目录
a=easygui.choicebox("“路人”中的目录",choices=["路人甲","路人乙","路过的机器人(智能AI)","EXIT"])
if a=="EXIT":
loop()
elif a=="路人甲"or a=="路人乙":
chat=""
newchat=easygui.textbox("(聊天记录已清空)","和"+a+"的聊天")
while True:
if newchat:
chat=chat+"\n"+person+":"+newchat
newchat=easygui.textbox(chat,"和"+a+"的聊天")
else:
loop()
else:
loop()
def loop():#重复QQ窗口
age=easygui.choicebox("“XX”的好友列表"+chr(10)+"昵称:无聊的木子",choices=["家人","同学","路人","智能机器人"])#进入“XX”的目录
if age=="家人":
family()
elif age=="同学":
classmate()
elif age=="路人":
passerby()
elif age=="智能机器人":
robot()
else:
easygui.msgbox("拜拜了"+chr(10)+"(;´༎ຶД༎ຶ`)","木子的QQ","离开")
exit()
import requests
import easygui
import time
import random
API_KEY="xxx"#你以为我会送你账号密码吗?
API_SECRET="XXX"
easygui.msgbox("欢迎来到木子的QQ!","木子的QQ","愉快地进入","1.gif")
easygui.msgbox("请先关注“无聊的木子”!博主等着呢")
person=None
while 1:
from easygui import*
password=multpasswordbox(msg="请输入账号及密码"+chr(10)+"(区分大小写)",title="李睿QQ",fields=["用户名","密码"],values=["admin","123456789"])
if password[0]=="1234567"or"1234567890"or"12345678":#验证账号
if password[1]=="XXXXXXXX": #验证密码
if password[0]=="1234567890":#验证身份(1)
easygui.msgbox("欢迎您,XX!","木子的QQ","进入QQ")
person="XX"
break
elif password[0]=="1234567890":#验证身份(2)
easygui.msgbox("欢迎您,XX!","木子的QQ","进入QQ")
person="XX"
break
elif password[0]=="1234567890":#验证身份(3)
easygui.msgbox("欢迎您,开发者!","木子的QQ","进入QQ")
person="XX"
break
else:
easygui.msgbox("账号或密码错误(a02)","木子的QQ")#密码错误
else:
easygui.msgbox("账号或密码错误(a01)","木子的QQ")#账号错误
easygui.msgbox("正在进入QQ......","木子的QQ","LOADING...")
time.sleep(random.randint(0, 3))
easygui.msgbox("成功进入QQ!","木子的QQ","进入")
loop()
好吧,拿(留)走(下)不(评)谢(论)
谢谢!