One - One Code All

Blog Content

python遍历目录,拼接域名

Python   2015-01-04 15:57:07

python遍历目录,拼接域名

import os

def walk(path):
    if not os.path.exists(path):
        return -1
    for root,dirs,names in os.walk(path):
        for filename in names:
            filepath = os.path.join(root,filename)
            filepath = "http://onecodeall.com/" + filepath
            filepath = filepath.replace("/ossfs/", "")
            print(filepath)

if __name__=='__main__':
    path = "/ossfs/images"
    walk(path)



上一篇:python中检测某个变量是否有定义
下一篇:python中pandas的dataframe行移动shift

The minute you think of giving up, think of the reason why you held on so long.