如何在python(提供的awk示例)文件分隔器中执行此代码
如果我想将以下awk代码作为python代码执行,那么最好的方法是什么?如果我要使用一个列表,我将如何弹出该列表,以便最终可以将字段1和3打印回输出列表并将其写入文件 谢谢 格雷厄姆 测试文件如何在python(提供的awk示例)文件分隔器中执行此代码,python,python-3.x,Python,Python 3.x,如果我想将以下awk代码作为python代码执行,那么最好的方法是什么?如果我要使用一个列表,我将如何弹出该列表,以便最终可以将字段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 2
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解决方案。因此,您最好包含输入文件的预期输出,从中,您可以在不查看AWK代码的情况下找出python解决方案
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
f = open(file_name)
for line in f:
s = line.split(':')
print s[0],s[2]