我很难弄清楚我要去哪里错了。
原始文件是:
python is a programming language that lets you WORK more quickly and integrate your systems more effectively.
you can learn to use python and see almost immediate gains in PRODUCTIVITY and lower maintenance COSTS.
it's very helpful for any field of study.
我正在尝试创建一个函数,该函数获取文件并读取它,然后将句子大写,将大写锁定更改为小写,将“it's”更改为“this is”。然后将文件放回原处并在句子后添加句点。将新文件字符串写入名为“Edited.txt”的 .txt 文件中。
我的代码是:
def edit(aFile):
f = open(aFile, 'r')
xs = f.readlines()
f.close()
g = open('happy.txt', 'w')
for x in xs:
x.capitalize()
if x.isupper==1:
x.lower()
g.write(x)
g.close()
我得到的错误是“找不到文件-happy.txt(访问被拒绝)。我试图读取文件但不能。
我 100% 肯定该文件在那里并且媒体路径设置为该文件夹。