我的网络设备输出的数据类型为unicode,如下所示。
Current System Time: Tue May 7 09:19:03 2019
PHY state linkDown 2 349 days, 8:47:08 ago
Interface state admin down 2 349 days, 8:47:05 ago
HW resets 0 never
Transceiver 10GBASE-SRL 2 349 days, 8:49:27 ago
Transceiver SN XCW1648FE1GR
Oper speed 10Gbps
Interrupt Count 0
Diags mode normalOperation
Model BCM88675/BCM88375 (0x18c086,0x37,0x0)
Loopback none
Xcvr EEPROM read timeout 0 never
Spurious xcvr detection 0 never
DOM control/status fail 0
Presence indication xcvrPresent 1 31 days, 9:32:27 ago
Bad EEPROM checksums 0 never
RX_LOS since system boot True 1 31 days, 9:32:27 ago
RX_LOS since insertion 1
TX_FAULT since system boot False 1 31 days, 9:32:27 ago
TX_FAULT since insertion 1
PMA/PMD RX signal detect no signal 0 never
PCS RX link status down 0 never
PCS high BER ok 0 never
PCS err blocks 0 never
PCS block lock no block lock 0 never
PCS BER 0 0 never
LN RXPPM CLK90 CLKP1 PF(M,L) VGA DCO DFE(1, 2, 3, 4, 5,dcd1,dcd2) TXPPM TXEQ(n1, m ,p1,p2,p3) BIP
0 20 32 0 0,0 0 0 0, 0, 0, 0, 0, 0, 0 0 12,100, 0, 0, 0 0
我们的目的只是打印此输出的第二行。 python中有什么办法吗?
答案 0 :(得分:1)
如果它是文本文件,其路径为“ C:\ output.txt”,则可以使用:
with open(r'C:\output.txt') as temp:
print(temp.readlines()[1])