'''
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'))