python 参数及简单文件操作
2017-10-04 11:55
309 查看
将变量传入脚本(所写的.py文件),命令中的****.py部分就是所谓参数.
from sys import argv // sys为模块也有人叫库,argv为参数变量,由软件包提供特性
from os.path import exists // 这个命令将文件名字符串作为参数,存在文件就返回True,否则Flase
script,from_file,to_file = argv
in_file = open(from_file)
indata = in_file.read()
out_file = open(to_file,'w')
out_file.write(indata)
out_file.close()
in_file.close()
这个代码运行不了就是大致的文件操作步骤。。。。。。。。。
from sys import argv // sys为模块也有人叫库,argv为参数变量,由软件包提供特性
from os.path import exists // 这个命令将文件名字符串作为参数,存在文件就返回True,否则Flase
script,from_file,to_file = argv
in_file = open(from_file)
indata = in_file.read()
out_file = open(to_file,'w')
out_file.write(indata)
out_file.close()
in_file.close()
这个代码运行不了就是大致的文件操作步骤。。。。。。。。。
相关文章推荐
- 文件行python 简单文件操作 修改文件指定行
- python简单文件操作
- Python学习笔记3:简单文件操作
- 简单文件操作python 修改文件指定行的方法
- Python(2.7.x)文件操作的简单示例
- python中简单的读写文件操作
- Python 第三篇(上):python文件基础操作、json模块、lambda、map、filter、reduce和函数位置参数
- python对文件的简单操作
- 用python作个简单文件拷贝操作
- [转]Python中关于文件路径的简单操作
- 【学习笔记】使用Python对文件进行简单操作
- python中关于文件路径的简单操作[zz]
- 我的Python学习之路之基本语法--参数传递、文件操作
- Python:简单的文件操作
- python 简单文件操作 修改文件指定行
- 简单文件操作python 修改文件指定行的方法
- Python学习笔记之简单文件操作
- python中关于文件路径的简单操作
- Python学习笔记3-文件的简单操作
- python中关于文件路径的简单操作