我正在试着打印一个特殊的行,如果找到匹配的这是我到目前为止。我有数据写入文件和显示,以便我可以看到什么过去。我想得到正则表达式匹配的所有数据,然后加上波段
这是从文件中读取的数据
DX de SP5FHF/ 7022.0 SP5FHF/5 SPFF0607
0917Z
DX de F4HUN: 7144.0 F2YT/P FFF-0686 73S PAUL
0917Z
代码文本
#!/usr/bin/env python
import re
import telnetlib
import time
HOST = "xxxxxxx"
PORT = 0000
user = "xxxxxx"
tn = telnetlib.Telnet(HOST,PORT)
tn.read_until(b"login: ")
tn.write(user.encode('ascii') + b"\n")
count = 0
timer = 0
print("Welcome to the KM4OUS Cluster Connector")
while (count < 1):
f = open("/home/w33ds/cluster.csv", "w")
push = tn.read_very_eager()
f.write(push.encode('utf-8'))
#print(push)
f.close()
f = open('/home/w33ds/cluster.csv','r')
regex = re.compile(r'(DX de .+\s142[2-9].+Z\s\w\w\w\w)|(DX de .+\s143[0-5].+Z\s\w\w\w\w)')
for x in f:
twenty = regex.findall(x)
for band in twenty:
band = re.sub('\'|\,|\(|\)','', str(band))
print(band)," 20M SSB"
f.close()
tcw = open('/home/w33ds/cluster.csv','r')
regex = re.compile(r'(DX de .+\s140[2-9].Z\s\w\w\w\w)')
for t in tcw:
twentyc = regex.findall(t)
for bandtc in twentyc:
bandtc = re.sub('\'|\,|\(|\)','', str(bandtc))
print(bandtc)," 20M CW DIGI"
tcw.close()
g = open('/home/w33ds/cluster.csv','r')
regex = re.compile(r'(DX de .+\s717[8-9].Z\s\w\w\w\w)|(DX de .+\s72[0-9].Z\s\w\w\w\w)|(DX de .+\s718.Z\s\w\w\w\w)')
for y in g:
forty = regex.findall(y)
for bandb in forty:
bandb = re.sub('\'|\,|\(|\)','', str(bandb))
print(bandb)," 40M SSB"
g.close()
cw = open('/home/w33ds/cluster.csv','r')
regex = re.compile(r'(DX de .+\s70[2-9].+Z\s\w\w\w\w)')
for z in cw:
fortyc = regex.findall(z)
for bandc in fortyc:
bandc = re.sub('\'|\,|\(|\)','', str(bandc))
print(bandc)," 40M CW DIGI"
time.sleep(5)
if timer == 30:
print (time.ctime() + "\nKM4OUS CLuster Connector")
cw.close()
count = 0
timer = timer+1
我想把整条线拉到代码的频率范围内。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐