结构sed函数不替换python文件中的字符串
我的fabfile.py中有以下函数结构sed函数不替换python文件中的字符串,python,sed,fabric,Python,Sed,Fabric,我的fabfile.py中有以下函数 def _update_settings(source_folder, site_name): settings_path = source_folder + '/superlists/settings.py' sed(settings_path, "DEBUG = True", "DEBUG = False") sed(settings_path, 'DOMAIN = "localhost"', 'DOMAIN = "%s"' %
def _update_settings(source_folder, site_name):
settings_path = source_folder + '/superlists/settings.py'
sed(settings_path, "DEBUG = True", "DEBUG = False")
sed(settings_path, 'DOMAIN = "localhost"', 'DOMAIN = "%s"' % (site_name,))
运行fabfile后,当site_name设置为tdd.box.tk
时,我有以下输出
DEBUG=False
DOMAIN='localhost'
而不是
DEBUG=False
DOMAIN='tdd.box.tk'
DOMAIN="localhost"
域未更改为传递的站点名称变量。
我知道问题出在字符串替换路径上,但无法解决它我能够找到解决方案。结果是在我的settings.py中
DOMAIN='localhost'
而不是
DEBUG=False
DOMAIN='tdd.box.tk'
DOMAIN="localhost"
sed
函数中的字符串必须与要替换的文件中的字符串完全匹配 我试图替换django settings.py文件中的调试设置,所以它实际上与间距无关