我有一个由两个句子组成的字符串元组
a = ('What', 'happened', 'then', '?', 'What', 'would', 'you', 'like', 'to', 'drink','?')
Run Code Online (Sandbox Code Playgroud)
我试过这个
for i,j in enumerate(a):
print i,j
Run Code Online (Sandbox Code Playgroud)
这使
0 What
1 happened
2 then
3 ?
4 What
5 would
6 you
7 like
8 to
9 drink
10 ?
Run Code Online (Sandbox Code Playgroud)
而我需要的就是这个
0 What
1 happened
2 then
3 ?
0 What
1 would
2 you
3 like
4 to
5 drink
6?
Run Code Online (Sandbox Code Playgroud) 我想在几个文档中替换几个字符串.我知道如何sed使用该-e选项组合命令,但我不知道如何在脚本中将它们组合在一起运行多个文件.
我尝试使用'for'循环,但它不起作用.
for i in `ls *.txt`; do sed -e 's/22/twenty two/g' \ -e 's/23/twenty three/g'$i > new/$i; done
Run Code Online (Sandbox Code Playgroud)
任何想法如何用做到这一点shell,awk,Python或Perl?