我是Python的新手,我试图创建一个脚本,该脚本将输出Aruba无线访问点SSID的配置文件。
我想为接入点提供一个线性输入,以逗号分隔,每个输入都将被读取并分配一个唯一的变量,然后将其在配置脚本中使用/调用。
这里最棘手的部分是访问点的数量不是固定的,因为它取决于用户请求。我想以一种可以容纳任何给定输入的方式制作脚本:
items = input("Enter the list of devices here: \n") ##
AP01,AP05,AP06,AP10,AP15 ## The list number is unknown as it varies depending on the need
并输出如下内容:
ap1 = items[0]
ap2 = items[1]
ap3 = items[2]
.
.
.
.
apn = items[n]
apconf1 = "ap-name" + " " + ap1\n + "vap-profile Test101_vprof"
apconf1 = "ap-name" + " " + ap2\n + "vap-profile Test101_vprof"
apconf1 = "ap-name" + " " + ap3\n + "vap-profile Test101_vprof"
.
.
.
.
apconfn = "ap-name" + " " + apn\n + "vap-profile Test101_vprof"
然后打印如下内容:
print(apconf1)
print(apconf2)
print(apconf3)
.
.
.
.
print(apconfn)
所需的输出是:
ap-name AP01
vap-profile Test101_vprof
ap-name AP05
vap-profile Test101_vprof
ap-name AP06
vap-profile Test101_vprof
.
.
.
.
ap-name APn
vap-profile Test101_vprof
任何输入将不胜感激。谢谢。
答案 0 :(得分:0)
您好,如果您将输入的信息输入列表,则可以解决问题
class SampleCallback(private var mContext: Context) : Callback<SampleResponse> {
override fun onResponse(call: Call<SampleResponse>, response: Response<SampleResponse>) {
when (response.code()) {
200-> //Update your View with mContext
}
}
}