def leggifile (nome): f=file(nome,'r'); testo=f.read() f.close(); return testo --------------------------------------- a=leggifile('diffusion.f') righe=a.split('\n') --------------------------------------- def scrivifile (nome,testo): f=file(nome,'w') f.write(testo); f.close() --------------------------------------- def scrivifilev (nome,testi,sep='\n'): f=file(nome,'w') for x in testi: f.write(x+sep) f.close() --------------------------------------- f=file('prova','w') f.write('Maria Tebaldi\n') f.write('Roberto Magari\n') f.write('Erica Rossi\n') f.close() --------------------------------------- def aggiungifile (nome,testo): f=file(nome,'a') f.write(testo); f.close() --------------------------------------- print os.path.split('/alfa/beta/gamma') # ('/alfa/beta', 'gamma') print os.path.split('/alfa/beta/gamma/') # ('/alfa/beta/gamma', '') print os.path.split('/') # ('/', '') print os.path.split('//') # ('//', '') - benche' '//' non sia correttamente formato. print os.path.split('/stelle') # ('/', 'stelle') print os.path.split('stelle/sirio') # ('stelle', 'sirio') --------------------------------------- v=sys.argv print v[0] a=leggifile(v[1]) print a --------------------------------------- v=sys.argv x=int(v[1]); y=int(v[2]) print x+y --------------------------------------- parola=sys.argv[1] def cesare (a): # Come a pagina 8 ... print cesare(parola) --------------------------------------- prova.py FORTISSIMISUNTBELGAE