The python implementation outputs the content Branch and the python Branch
# Branch output of a line of content in python
A = "aA1 one bB2 two cC3 three dD4 four eE5 five fF6 six gG7 seven hH8 eight iI9 nine" branch output: abcdefghiABCDEFGHI123456789 February "print (" Method 1: ====================== ") for r in range ): t = ''for s in range (0 + r, len (a), 4): t = t + a [s] print (t) print (" Method 2: ==================== ") #==_ = will this method look silly? L = list (a) ta = tb = tc = td = ''for r in range (0, 9): for s in range (0, 4): if s = 0: ta = ta + l. pop (0) if s = 1: tb = tb + l. pop (0) if s = 2: tc = tc + l. pop (0) if s = 3: td = td + l. pop (0) print (ta) print (tb) print (tc) print (td) print ("method 3: there are N writing methods for the response: ================== ") import stringta = tb = tc = td ='' la = string. ascii_lowercaseua = string. ascii_uppercasenb = string. digitsub = "September 1234" for s in a: if s in la: ta = ta + s if s in ua: tb = tb + s if s in nb: tc = tc + s if s in ub: td = td + sprint (ta) print (tb) print (tc) print (td) print ("method 4: there is a way to write a regular expression = ") import re # This regular expression is not scientific, no good idea for Now reg = ["[a-z]", "[A-Z]", "\ d ", "[^ \ da-zA-Z]"] for s in reg: rega = re. compile (s) s = re. findall (rega, a) print ("". join (s) "output: Method 1: ==================== abcdefghiABCDEFGHI123456789 1234 five, six, and nine methods 2: ================== abcdefghiABCDEFGHI123456789 method 3: there are N writing methods for returning characters ================== abcdefghiABCDEFGHI123456789 Method 4: there is a way to write a response called regular expression ================== abcdefghiABCDEFGHI123456789 1234 """
Let's give you another way to read the file content and output it by branch.
f=open("shuju.txt","r")content=f.read()print contentfor i in content: print if.close()f=open('shuju.txt','w')f.write(content)f.close()
Well, it's interesting to study it by yourself.