【发布时间】:2019-04-27 17:03:43
【问题描述】:
例如这是我的 python 文件,即 client.py,我希望将在此文件中生成的数据(ID、Ip_add、mac_address 导出到新的 csv 文件中。)
#client.py
import random
import socket
# funtion to define no. of switch
def switch_info(no_of_switch):
for number in range (1,no_of_switch+1):
print("ID:s",+number)
ip_add = '127.0.0.' + str(random.randint(0, 255))
print("IP_address:{}".format(ip_add))
mac_add = "-".join(map(str,(random.randint(0,255)for _ in range(4))))
print("Mac_address:{}".format(mac_add))
print('\n')
switch_info(2)
【问题讨论】:
-
我必须创建一个网络拓扑,其中包括相互连接的交换机、客户端、网关和路由器(个人 ID、ipadd、macadd、状态),然后我必须编写代码来创建csv 文件,其中包含网络中每个参与者的信息......最后我必须通过任何可视化工具展示网络。
标签: python-3.x csv networking topology