我正試圖以這種方式從Python中調用gawk(AWK的GNU實現)。從Python調用gawk
import os
import string
import codecs
ligand_file=open("2WTKA_ab.txt", "r") #Open the receptor.txt file
ligand_lines=ligand_file.readlines() # Read all the lines into the array
ligand_lines=map(string.strip, ligand_lines)
ligand_file.close()
for i in ligand_lines:
os.system (" gawk %s %s"%("'{if ($2==""i"") print $0}'", 'unique_count_a_from_ac.txt'))
我的問題是,「我」不是被它代表的值所代替。值「我」表示是一個整數,而不是一個字符串。我該如何解決這個問題?
不要使用'os.system':改爲使用子進程(請參閱http://docs.python.org/library/subprocess.html)! – ChristopheD 2010-03-21 00:49:18