1
如果我想将以下awk代码编译为python代码,那么最好的方法是什么?如果我要使用列表,我将如何弹出列表,以便最终可以将字段1和3打印回输出列表并将其写入文件。我该如何在python(awk示例提供的)文件分隔符中执行此代码
感谢 格雷厄姆
AWK
#!/bin/awk -f
BEGIN {
FS=":";
}
{
print $1,$3
}
测试文件
Error code 27: This is error code 27:Ihave no comment here
Error code 24: This is error code 27:Ihave no comment here
Error code 27: This is error code 27:Ihave no comment here
Error code 26: This is error code 27:Ihave no comment here
Error code 27: This is error code 27:Ihave no comment here
Error code 29: This is error code 27:Ihave no comment here
Error code 01: This is error code 27:Ihave no comment here
我真的不说话AWK,我怀疑有很多Python程序员在那里谁既不。所以你最好包括输入文件的预期输出,因此,可以在不查看AWK代码的情况下找出python解决方案。 – bpgergo 2012-08-01 12:32:19