如何過濾兩個時間戳之間的線條並僅在Python中打印這些線條?如何使用Python 3在兩個時間戳之間打印行?
例如:我想過濾08:00:00 am至05:00:00 pm我嘗試了一些這樣的事情,但它不起作用。
def ipaddr(w):
print("====Welcome to HTTP log Debugger ==== ")
file= input("Please Enter log File path: ")
start_time = input("start Time: ")
End_time = input("End Time : ")
with open(file,'r') as f:
lines = f.read().splitlines()
for L in lines:
if L.startswith(start_time):
p= 1
elif L.startswith(End_time):
p=0
break
if p: print(L)
提供樣本的輸入數據。請閱讀[this](http://stackoverflow.com/help/mcve) – Pynchia
並且比*「它不工作」更具體*。 – jonrsharpe