简体   繁体   中英

Trying to capital first letter in line of wordlist and export to new file name = output

I'm trying to capitalize the first letter in every line of this file which is a wordlist and then export it to new file name = output but when I submit script to print the file is empty and all I get to print via terminal is the first word can someone help me please

Thanks I'm new at this but trying real hard to learn to script on my own it's been about a week of trying different variations but I always get the same result lol

However I can get it to print the whole list via terminal but it does seem to kill before finishing the list !

Thanks for any help

This is my script:

 input = ("f","r")
 output = ("f","w")

 with open ("file1.txt","r") as f, open ("file2.txt","w") as output:
   For x in f:
      For words in f:
        Words = x.capitalize()    
   Print (words)
   Print (output)
with open ("file1.txt","r") as f, open ("file2.txt","w") as output:
    for x in f.readlines():
        output.write(x.capitalize())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM