将双引号和逗号附加到值

时间:2015-10-30 10:25:42

标签: python for-loop format

考虑以下代码,其中包含IP地址。

#loop through the list
for ip in ips:
        #I know there is argument as to whether the string join method is pythonic
        addy = "".join(ip)
        if addy is not '':
                print addy

这里最后打印addy将简单地打印结果(即:IP地址)。

但不是我需要的是结果应按以下顺序打印。

考虑它有三个结果1.2.3.4。 1.2.3.6 1.2.3.8。

应按以下格式打印。

“1.2.3.4”, “1.2.3.6”, “1.2.3.8”

注意:IP的数量将根据时间而有所不同。

0 个答案:

没有答案
相关问题