rsync fedora repository

USTC rsync 服务地址 rsync://rsync.mirrors.ustc.edu.cn (智能解析,推荐) rsync://cernet.mirrors.ustc.edu.cn(仅解析教育网,推荐) rsync://mobile.mirrors.ustc.edu.cn(仅解析中国移动) USTC Repository 同步状态 https://mirrors.ustc.edu.cn/status/ mirors for rpmfusion by rsync: rsync -avrzP rsync://rsync.mirrors.ustc.edu.cn/rpmfusion/free/fedora/releases/24/Everything/x86_64/os/ ./os mirrors for fc24 by rsync: rsync -avrzP rsync://mirrors.tuna.tsinghua.edu.cn/fedora/releases/24/Everything/x86_64/os/ ./os »

替换文件中的字符串

替换文件中的字符串 将文件中的字符串全部替换,并生成新的文件,如:执行’replace.py ntfs xfs sysInfoin sysInfoout’将把sysInfoin文件中的所有’ntfs’替换为’xfs’并写入sysInfoout文件。 代码中使用了 ‘*args’ 这样的可变参数列表,参数将以一个元组的形式传递到函数中;在本段代码中对args的tuple数量判断是不必要的,但针对 ‘replace_text’ 这个函数来说这个判断是有必要的; 代码中使用了 with … as … 这样的控制流语句,在 with 结束后将自动关闭所打开的文件; #!/usr/bin/python # -*- coding: utf-8 -*- """Replace string from a file to another file.""" import os import sys usage = "Usage: %s search_txt replace_text [infilename [outfiename]]." % os.path.basename(sys.argv[0]) def replace_text( *args): opt_args = args[0] if len(args) ==1 else None if not opt_args: print 'Error : There are %d tuple args in function : ' % len(args), args sys. »