代码:
<pre># coding=utf-8 import os import shutil import traceback def move_file(src_path, dst_path, file): print 'from : ', src_path print 'to : ', dst_path try: # cmd = 'chmod -R +x ' + src_path # os.popen(cmd) f_src = os.path.join(src_path, file) if not os.path.exists(dst_path): os.mkdir(dst_path) f_dst = os.path.join(dst_path, file) shutil.move(f_src, f_dst) except Exception as e: print 'move_file ERROR: ', e traceback.print_exc() src_path= '/xacisco-blog/文章' dst_path= '/xacisco-blog/文章/已经读取' move_file(src_path,dst_path,'测试文件.txt')