Vamei Source: Http://www.cnblogs.com/vamei Welcome reprint, Please also keep this statement. Thank you!
Original chain: Http://www.cnblogs.com/vamei/archive/2012/07/19/2600135.html#!comments
NOTES: Semi-finished, make a look
" "file = open (' D:/record.txt ', ' W ') print (file.name) file.write (' tom,12,86\nlee,15,99\nlucy,11,58\njoseph,19,56 ') File.close () file = open (' D:/record.txt ', ' r ') lines = File.readlines () print (lines)" "#The above is the previous homework, this section may be used .#I don't know how much to say, 23.#This is a small topic, the author has arranged some homework, looked not to write, looked at the review, also someone wrote very good very professional, also have a problem with me the same#from the earliest chapter of a chapter to see, read the job directly confused forced#The author said that will use the standard library of things, first try to thank you see, will not be updated later#Write a program to determine if 2008 is a leap year#It's been written before, and it's almost forgotten .#pull the leap year concept again: years that can be divisible by 4 but not divisible by 100, or divisible by 400#find remainder% modulus-returns the remainder of DivisiondefRun (y):ifY% 4 ==0 andY% 100! =0:Print(r'Leap Year') elifY% 400 = =0:Print(r'Leap Year') Else: Print(r'Not leap year')#Let's change common year. Forgive only know notRun (2008)#The role of R do not remember, only remember that the following string can be entered in Chinese#Write a program that calculates October 1, 2008 is the day of the year? (January 1, 2008 is the first day of the year)#idea: should be judged first leap year common year, if common year with 365 this calculation, Leap year 366 calculation" "There is a record.txt document with the following contents: # Name, age, Scoretom, 86Lee, 99Lucy, 19, 56 The first column is the name, the second column is old, and the third column is Score (score) Now, write a Python program, 1) read the file 2) print the following results: who scored below 60? Whose name begins with L? What is the total score for all? 3) The first letter of the name needs to be capitalized, does the record.txt meet this requirement? How to correct the wrong place? " "#line = File.readlines () reads all rows, returns the listfile= Open ('D:\\record.txt','R') forLinesinchFile:Print(lines)#For loop printing each line, is a teacher who has worked#also taught by the space to separate, and then write to Excel, but forgotfile= Open ('D:\\record.txt','R') Line=File.readlines ()Print(line)Print(line[0])Print(Type (line))Print(Type (line[0]))
Update the previous leap year judgment code
def Run_nian (year): if and a%! =0: return True if year% = =0:
return
True
Else
:
return False
Python Learning notes (23) semi-finished work