Entering edit mode
6.4 years ago
v27
▴
10
i have written a program to detect the bidirectional hit. which is as follows
query = open("abc.txt","r").readlines()
database = open("cba","r").readlines()
Q2Ddict = {}
for line in query:
Q2Ddict[line.rsplit()[0]] = line.rsplit()[1]
D2Qdict = {}
for line in database:
#print(line.rsplit()[0],line.rsplit()[1])
D2Qdict[line.rsplit()[0]] = line.rsplit()[1]
for qtd,dbs in Q2Ddict.items():
for dbq,qts in D2Qdict.items():
if(qtd == qts and dbs == dbq):
print(qtd,dbs)
and the output generated is :
WP_003691339.1 WP_003691339.1
WP_010360713.1 WP_010360713.1
WP_003690758.1 WP_003690758.1
WP_003688953.1 WP_003688953.1
WP_047916891.1 WP_012503426.1
WP_002244992.1 WP_002244992.1
WP_003688378.1 WP_010356285.1
the problem is : that after every a new line is being inserted. (to remove that in perl there is a command chomp). how and where to use a similar command in python?
I don't know if I understand your question, but print() will put a new line at the end unless you tell it not to (
print(, end="")
). What's your desired output?The print function has an argument that you can use
end can be any char or scape char