关闭

python 实现大小写替换

标签: python 大小写替换
490人阅读 评论(0) 收藏 举报
分类:

change_char.py

#!/usr/bin/env python
#Filename:readfile.py
codelist=[]
codetotal=[]
f=file('input.txt','r')
for line in f.readlines():
     line=line.strip('\n')
     codelist=line.split(' ')
     for i in codelist:
         string=i
         string_temp=''
         for j in string:
                print j
                if j.isupper():
                     
                   string_temp=string_temp+j.lower()
                elif j.islower():
                    
                   string_temp=string_temp+j.upper()
                else :
                    string_temp=string_temp+j
         print string_temp
         codetotal.append(string_temp)
print codetotal
fo=file('output.txt','w')
for i in codetotal:
   

       fo.write(i)
       fo.write(" ")
f.close()
fo.close()
input.txt
Reference of the C++ Language Library, with detailed descriptions of its elements and examples on how to use its functions
The standard C++ library is a collection of functions, constants, classes, objects and templates that extends the C++ language providing basic functionality to perform several tasks, like classes to interact with the operating system, data containers, manipulators to operate with them and algorithms commonly needed.
output.txt
rEFERENCE OF THE c++ lANGUAGE lIBRARY, WITH DETAILED DESCRIPTIONS OF ITS ELEMENTS AND EXAMPLES ON HOW TO USE ITS FUNCTIONS tHE STANDARD c++ LIBRARY IS A COLLECTION OF FUNCTIONS, CONSTANTS, CLASSES, OBJECTS AND TEMPLATES THAT EXTENDS THE c++ LANGUAGE PROVIDING BASIC FUNCTIONALITY TO PERFORM SEVERAL TASKS, LIKE CLASSES TO INTERACT WITH THE OPERATING SYSTEM, DATA CONTAINERS, MANIPULATORS TO OPERATE WITH THEM AND ALGORITHMS COMMONLY NEEDED. 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:182682次
    • 积分:3284
    • 等级:
    • 排名:第10351名
    • 原创:132篇
    • 转载:79篇
    • 译文:1篇
    • 评论:13条
    最新评论