[习题] 指定一个源文件,实现copy到目标目录.例如把/tmp/sample1.txt 拷贝到/tmp/sample2.txt原文件需要有读权限(默认rt权限),目标文件需要给写(w即可)权限. In [8]: with open('/tmp/sample1.txt',encoding='UTF-8') as f1: ...: with open('/tmp/sample2.txt','w',encoding='utf-8') as f2: ...: content = f1.read() .
python小练习1:设计这样一个函数,在桌面的文件夹上创建10个文本,以数字给它们命名. 使用for循环即可实现: for name in range(1,11): desktop_path='C://Users/Lenovo/Desktop/' full_path=desktop_path+str(name)+'.txt' file=open(full_path,'w') file.close()