标签:stack pre question 字符串 ref str lin col 转换
它是由逗号分隔的几个值的序列:
mStr = ‘192.168.1.1,192.168.1.2,192.168.1.3‘
如何将字符串转换为列表?
mStr = [‘192.168.1.1‘, ‘192.168.1.2‘, ‘192.168.1.3‘]
>>> mStr = ‘192.168.1.1,192.168.1.2,192.168.1.3‘ >>> mStr.split(",") [‘192.168.1.1‘, ‘192.168.1.2‘, ‘192.168.1.3‘]
>>> mlist = mStr.split(",") >>> tuple(mlist) (‘192.168.1.1‘, ‘192.168.1.2‘, ‘192.168.1.3‘) >>>
标签:stack pre question 字符串 ref str lin col 转换
原文地址:https://www.cnblogs.com/clement-jiao/p/9043110.html