1.判断字符串是否为小数
try:
lat = float(location.split(',')[1])
lon = float(location.split(',')[0])
except...open('test.txt','rb')
f_read=f.read()
f_charInfo=chardet.detect(f_read)
print(f_charInfo)
# f_charInfo的输出是这样的的一个字典...{'confidence': 0.99, 'encoding': 'utf-8'}
4.将逗号分隔的字符串转换为列表
给定一个字符串:
它是由逗号分隔的几个值的序列:
mStr = '192.168.1.1,192.168.1.2,192.168.1.3...'
如何将字符串转换为列表?...[ [a,b] for a,b in zip(list1,list2)]
生成一个以列表list1,list2各项合并列表为元素的列表