本文主要是介绍Python for Everybody(PY4E) Chapter7,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
小白自学,仅作为个人记录。
Exercise 1: Write a program to read through a fifile and print the contents of the fifile (line
by line) all in upper case. Executing the program will look as follows:
fname = input('Enter the file name: ')try:fhand = open(fname)except:print('File cannot be opened:', fname)exit()for line in fhand:line = line.upper()print(line)
Exercise 2: Write a program to prompt for a file name, and then readthrough the file and look for lines of the form:
这篇关于Python for Everybody(PY4E) Chapter7的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!