# 2. Open an English text file, write a program to read its contents, and the uppercase and lowercase characters were interchangeable, other characters do not change
F2 = Open ( "test2.txt", "r")
contents2 = f2.readlines ()
Print (contents2)
f2.close ()
# result2 = []
# for STR in contents2:
# result2.append (str.swapcase ())
result2 = [str.swapcase () for STR in contents2]
Print (result2)
F2 = Open ( "is test2.txt", "W")
f2.writelines (result2)
f2.close ()
Pythone: 07 English text: read the contents of other constant exchange capitalization
Guess you like
Origin blog.csdn.net/weixin_44015669/article/details/104101392
Recommended
Ranking