test.py 723 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/eny python
  2. # _*_coding:utf-8_*_
  3. from img import img
  4. import xiaobing
  5. import json
  6. def test(url):
  7. result = img(url)
  8. content = u'图中识别出 %d 张人脸 \n' % (len(result))
  9. print (result)
  10. for i in result:
  11. content += i['sex'] + ' ' + i['age'] + u'岁' + '\n'
  12. return content
  13. # print (test('http://mmbiz.qpic.cn/mmbiz_jpg/hWWXn4JfVmia8Giatv3h0Ge82jdbAjOFF962Laiasl7Pu2Sx3qibdQzqTFFnpnFYPwuCuMwXXia7eHs9zb0nibsaFM2g/0'))
  14. def xb(info):
  15. xb = xiaobing.xiaoiceApi()
  16. text = xb.chat(info)
  17. print (text)
  18. if text['status'] == 'succeed':
  19. text = text['text']
  20. else :
  21. text = u'小冰消失啦,请稍后再试!'
  22. return text
  23. print(xb('你怎么啦'))