from sys import argv
from os.path import exists
#又import了一个命令exists,这个命令将文件名字符串作为参数,如果文件存在返回TRUE,否则返回FALSE script,from_file,to_file=argv
#传参,不过没有管exists哎 print("copying from %s to %s "%(from_file,to_file))
#打印copying from "from_file"to "to_file" get=open(from_file)
#打开“from_file”并传递给对象get
indata=get.read()
#读文件然后传给indata print("the input file is %d bytes long"%len(indata))
#打印the input file is “一个数字”bytes long
print("does the output file exist?%r"%exists(to_file))
#打印does the output file exist?+true/false(有就是true)
print("ready,hit RETURN to continue ,CTRL-C to abort.")
#打印ready,hit RETURN to continue ,CTRL-C to abort.
input('<')
#一个提示符
output=open(to_file,'w')
#以只写的模式打开“to_file”
output.write(indata)
#把indata里的内容(from_file)写进output(to_file) print("alright,all done")
#打印alright,all done
output.close()
#关闭output
get.close()
#关闭get
copied=open("copied.txt")
print(copied.read())
#查看文件咯

5.18-笨办法学python-习题17(文件拷贝)的更多相关文章

  1. 笨办法学Python - 习题1: A Good First Program

    在windows上安装完Python环境后,开始按照<笨办法学Python>书上介绍的章节进行练习. 习题 1: 第一个程序 第一天主要是介绍了Python中输出函数print的使用方法, ...

  2. 笨办法学Python - 习题11-12: Asking Questions & Prompting People

    目录 1.习题 11: 提问 2.习题 12: 提示别人 3.总结 1.习题 11: 提问 学习目标:了解人机交互场景,熟悉raw_input 的用法. 1.在 Python2.x 中 raw_inp ...

  3. 笨办法学Python - 习题8-10: Printing & Printing, Printing

    目录 1.习题 8: 打印,打印 2.习题 9: 打印,打印,打印 3.习题 10: 那是什么? 3.1.转义序列: 4.习题总结: 1.习题 8: 打印,打印 学习目标:继续学习 %r 的格式化输出 ...

  4. 笨办法学Python - 习题6-7: Strings and Text & More Printing

    目录 1.习题 6: 字符串(string) 和文本 2.加分习题: 3.我的答案 4.习题总结 5.习题 7: 更多打印 6.习题总结 1.习题 6: 字符串(string) 和文本 学习目标:了解 ...

  5. 笨办法学Python - 习题5: More Variables and Printing

    1.习题 5: 更多的变量和打印 学习目标:了解用户输入方法,明白pthon2和Python3之间的用户输入的区别.了解格式化字符串(format string)的概念,学会如何创建包含变量内容的字符 ...

  6. 笨办法学Python - 习题4: Variables and Names

    1.习题 4: 变量(variable)和命名 学习目标:了解Python中变量的定义,学习定义简明易记的变量名 变量:变量是存储内存中的值,就是每定义一个变量就会在内存中开辟一个空间.基于变量的类型 ...

  7. 笨办法学Python - 习题3: Numbers and Math

    目录 习题 3: 数字和数学计算 算术运算符 加分习题: 我的答案: 总结: 扩展: Python比较运算符 Python赋值运算符 Python位运算符 Python逻辑运算符 Python成员运算 ...

  8. 笨办法学python 习题14 优化过 遇到问题的请看

    print "\t what's you name?"user_name = raw_input('>') from sys import argvscript, = arg ...

  9. 笨办法学 Python (Learn Python The Hard Way)

    最近在看:笨办法学 Python (Learn Python The Hard Way) Contents: 译者前言 前言:笨办法更简单 习题 0: 准备工作 习题 1: 第一个程序 习题 2: 注 ...

  10. 笨办法学 Python (第三版)(转载)

    笨办法学 Python (第三版) 原文地址:http://blog.sina.com.cn/s/blog_72b8298001019xg8.html   摘自https://learn-python ...

随机推荐

  1. December 15th 2016 Week 51st Thursday

    At the touch of love everyone becomes a poet. 每一个沐浴在爱河中的人都是诗人. You call your love as your sweetheart ...

  2. iOS自动化-iOS录屏xrecord及解决iPhone设备不显示的问题

    github地址:https://github.com/WPO-Foundation/xrecord 安装方法: git clone https://github.com/WPO-Foundation ...

  3. 在Android Studio2.3中配置OpenCV4Android SDK

    在Android Studio2.3中配置OpenCV4Android SDK 一,OpenCV4Android下载地址 [2.4.11]http://onhdz331f.bkt.clouddn.co ...

  4. 本机未装Oracle数据库时Navicat for Oracle 报错:Cannot create oci environment 原因分析及解决方案

    因为要更新数据库加个表,远程桌面又无法连接...所以就远程到另外一台电脑,然后用navicat通过内网修改目标数据库. 一直用着navicat操作数据库,所以很速度的弄好然后新建连接进入数据库. 然而 ...

  5. select下拉的绑定及回显(ajxa)

    下拉列表一般通过ajax请求数据绑定 // 绑定新闻类型下拉 function news_type() { var news_type=$("#news_type").val(); ...

  6. 问题:从键盘读取特定类型的数据(使用Scanner读取int类型)

    import java.util.Scanner; public class ScannerIntTest{ public static void main(String [] args){ int ...

  7. 【[SDOI2013]泉】

    \(hash\)+容斥 但是看到这个令人愉快的数据范围还是直接枚举子集吧 首先我们发现\(6\)这个东西简直是小的可怜,复杂度里肯定有\(2^6\)的 于是我们可以直接先枚举子集,把所有状态的对应相等 ...

  8. SpringBoot实战(五)之Thymeleaf

    Thymeleaf同jsp.volocity.freemarker等共同的职能是MVC模式中的视图展示层,即View. 当然了,SpringBoot中也可以用jsp,不过不推荐这种用法,比较推崇的就是 ...

  9. (转)ci

    1  从代码管理器签出源文件 2  修改代码 3  编译代码 4  遇到错误,转到2继续修改直到达到预期 5  运行单元测试,期望所有的测试绿色(通过) 6  单元测试出错,转入2 7  重构代码,按 ...

  10. CVPR2018_Crafting a Toolchain for Image Restoration by Deep Reinforcement Learning

    CVPR2018_Crafting a Toolchain for Image Restoration by Deep Reinforcement Learning http://mmlab.ie.c ...