美好的一天.关于reg exp的小问题.
我有一个字符串看起来像
http://servercom/smth/Age=&Filter=2&
Run Code Online (Sandbox Code Playgroud)
我怎么能用&url的regexp 剪切?
在regexp之后url-string必须是 http://server.com/smth/Age=1&Filter=2&
我正在尝试编写一个Python脚本,该脚本从文件中读取字符串行并执行bash-shell命令,每行作为参数:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
lines = [line.strip() for line in open('/tmp/i586rpm.txt')]
for rpm in lines:
try:
s = os.system("rpm -qip") % lines
except Exception:
print "Something wrong"
Run Code Online (Sandbox Code Playgroud)
但我总是得到一个错误.我认为有一些问题% lines.
有任何想法吗?