Advertisement
Dar954826

IA[ITA].py

Jan 1st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: latin-1 -*-
  3. def IA():
  4.  import random,sys,os
  5.  global dir1,dir2
  6.  inp=""
  7.  open("question.txt","w")
  8.  open("answer.txt","w")
  9.  while True:
  10.   ra=open("question.txt","r")
  11.   rb=open("answer.txt","r")
  12.   a=open("question.txt","a")
  13.   b=open("answer.txt","a")
  14.   cacheAns=cacheAns1=rb.read()
  15.   cacheAns=cacheAns.split("|")
  16.   cacheQue=cacheQue1=ra.read()
  17.   cacheQue=cacheQue.split("|")
  18.   try:
  19.    inl=input("Chiedi Qualcosa: ")
  20.    print(cacheQue[cacheAns.index(inl)])
  21.   except ValueError:
  22.    z=input("Non conosco questa domanda, cosa dovrei rispondere? ")
  23.    a.write("|"+inl)
  24.    b.write("|"+z)
  25.    a.close()
  26.    b.close()
  27. while True:
  28.  IA()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement