[英]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我正在尝试将这个文件的每一行中的第一个字母大写,这是一个单词列表,然后将其导出到新文件名 = output 但是当我提交脚本来打印文件是空的,我可以通过终端打印的是第一个词有人可以帮我吗
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())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.