我是 Python 新手,正在尝试学习使用 for 语句以某种方式显示信息……有没有办法使用 for 语句来显示这样的列表?
w = "Fa1/1 connected 42 a-full a-100 10/100BaseTX"
v = w.split()
x=v[0]
print "Port ", x
y=v[1]
print "Status ", y
z=v[2]
print "VLAN ", z
a=v[3]
print "Duplex ", a
b=v[4]
print "Speed ", b
c=v[5]
print "Type ", c
-------------------------
Port Fa1/1
Status connected
VLAN 42
Duplex a-full
Speed a-100
Type 10/100BaseTX
我尝试了很多不同的方法,但不断收到价值和索引错误....
谢谢你的帮助....