FileExp.py
来源:互联网 发布:简单网络拓扑图怎么画 编辑:程序博客网 时间:2024/06/06 11:49
'''
Created on 2014-10-30
@author: XSD
'''
import os
class FileExp:
'''
example class <FileExp>
'''
def __init__(self):
'''
初始化对象
'''
# if type(params) != type({}):
# raise TypeError("error type %s" % type(params))
# self.items = params
# return
def make_file(path): #@NoSelf
'''
创建文件
'''
oper = 'a' if os.path.isfile(path) else 'w'
newFile = open(path, oper)#打开并写入数据
newFile.write('''中国
南京''')
print('operate over')
t = open(path, 'r')#打开文件读取内容
# print(t.readline())
# print(t.read())
text = t.readlines()
for line in text:
print(len(line))
t.close()
# del t
def split_file_path(path):
'''
递归...
'''
parent_path, name = os.path.split(path)
print("p_path>", parent_path, " file>", name)
if name == "":
return (parent_path,)
else:
return split_file_path(parent_path) + (name,)
if __name__ == "__main__":
print(split_file_path('c:/user/util/_init.py'))
Created on 2014-10-30
@author: XSD
'''
import os
class FileExp:
'''
example class <FileExp>
'''
def __init__(self):
'''
初始化对象
'''
# if type(params) != type({}):
# raise TypeError("error type %s" % type(params))
# self.items = params
# return
def make_file(path): #@NoSelf
'''
创建文件
'''
oper = 'a' if os.path.isfile(path) else 'w'
newFile = open(path, oper)#打开并写入数据
newFile.write('''中国
南京''')
print('operate over')
t = open(path, 'r')#打开文件读取内容
# print(t.readline())
# print(t.read())
text = t.readlines()
for line in text:
print(len(line))
t.close()
# del t
def split_file_path(path):
'''
递归...
'''
parent_path, name = os.path.split(path)
print("p_path>", parent_path, " file>", name)
if name == "":
return (parent_path,)
else:
return split_file_path(parent_path) + (name,)
if __name__ == "__main__":
print(split_file_path('c:/user/util/_init.py'))
0 0
- FileExp.py
- py
- py
- py
- py
- py
- py
- py
- Py
- bin2hex.py && hex2bin.py
- web.py (url.py)
- [py]py存放家具
- Xctf之调皮的py-py-py
- dir_size.py
- sendEmail.py
- Html.py
- web.py
- mail.py
- 鸟哥的私房菜笔记之linux中的在线求助
- 企业展览设计原则
- codeforces #284 div2 ABCD*E*
- eclipse运行JSP文件时,提示tomcat错误
- Apache Commons Validator 一些内容
- FileExp.py
- Maven教程初级篇01: 简介
- python numpy使用
- How ECMAScript 5 still does not allow to subclass array
- Win7 x64 Eclipse无法识别手机 / adb interface有黄色感叹号,无法识别
- User.py
- IOS图片保存到本地相册
- cocostudio之如何制作界面布局
- ScrollView嵌套ListView的显示问题