Python读取文件
来源:互联网 发布:oa 办公系统java实现 编辑:程序博客网 时间:2024/05/06 01:24
from sys import argvscript,filename = argvtxt = open(filename)//从命令行参数获取文件名print("Here's your file %r:" %filename)#%rprint(txt.read())print("I'll also ask you to type it again:")file_again = input(">")#二次读取,从程序内部输入文件名txt_again = open(file_again)print(txt_again.read())
从上篇文章,学过了命令行的使用方法,上段代码中从命令行中获取到文件的名字,通过open("filename")来打开文件,txt.read()方法来读取文件中的内容。
0 0
- Python文件读取说明
- python多线程读取文件
- Python-读取csv文件
- Python读取pcap文件
- python读取文件
- python 读取文件
- python读取CSV文件
- python读取文件小结
- Python文件的读取
- python读取文件
- python读取xml文件
- python 读取文件
- python读取大文件
- Python读取文件
- python读取文件
- python读取xml文件
- python读取xml文件
- python读取xls文件
- datalist 分页
- POJ 3278 水BFS
- java 实现根据url,将url对应的网页存为一张完整的图片,不是截图,也就是图片是整个网页的内容
- java反射练习
- POJ1060 Modular multiplication of polynomials解题报告 (2011-12-09 20:27:53)
- Python读取文件
- C++内存分配方式详解——堆、栈、自由存储区、全局/静态存储区和常量存储区
- POJ 3080 Blue Jeans
- URAL 1551 Sumo Tournament
- apache中openssl,no ssl,ftp,还有fcgid的区别
- eclipse maven 插件
- TINY4412 驱动开发学习笔记整理---内存管理篇
- VB.NET版机房收费系统---外观层如何写
- CentOS下源码安装PostgreSQL