Wednesday 15 February 2012

python - why wont my tk program write to a file? -


I have created a typewriter program that writes user data in a file, but when changing the numbers in the variable

This file is being written in:

  .15212688 .15213328 .15213232 INVALID REGISRATION NUMBER  

And this is my code: < / P>

  def show_entry_fields (): # creates a function called show entry field. Print ("First name:% s \ nThe following name:% s \ n Registration number:% s"% (Fname.get), Lname.get (), reg.get ())) If re.match ('^ [A-Za-z] {2} [0- 9] {2} [AZA-ZED] {3} $ ', reg.get ()): #Unsers that he is right in #WF # User has been told that reg is not valid data: # wfconfigure (text = 'this is a valid registration number') # if reg is valid, # user data is 'invalid' Data are written in the file by name. Write (str (Fname)) # First name data. Written ('\ n') # New line data # New line data. Write (str (Reg)) # Regression number data for CAS. Write ('\ n') # Write new line data (str (LNA)) # Last name data. Written ('' \ n 'write (' INVALID REGISRATION NUMBER ') # perpiose.close (#  

If someone can tell me in the right direction, then thank you in advance

You should use

  data. Write (str (Fname.get ()) # # First name data.write ('\ n ') # New line data. Write (str (Lname.get ()) # Last name data.write (str (reg.get ()))  

Your In the code you are converting objects for strings


No comments:

Post a Comment