教程集 www.jiaochengji.com
教程集 >  Python编程  >  python进阶  >  正文 python怎么分读txt中逗号

python怎么分读txt中逗号

发布时间:2021-01-12   编辑:jiaochengji.com
教程集为您提供python怎么分读txt中逗号等资源,欢迎您收藏本站,我们将为您提供最新的python怎么分读txt中逗号资源
python分读txt中逗号的方法:可以使用split函数对txt文件中的逗号进行读取,split函数的作用是拆分字符串,通过指定分隔符对字符串进行切片。

python分读txt中逗号可以用split()函数

fname = './data/loc.txt' 
 with open(fname, 'r ', encoding='utf-8') as f:
    s = [i[:-1].split(',') for i in f.readlines()]

您可能感兴趣的文章:
python怎么分读txt中逗号
python怎么读取txt文件内容
python怎么读取文本文件
批处理教程之FOR的参数/F之delims详解
Python怎么表示一个列表
python怎么读写文件
python怎么打印变量
Python列表怎么更新值?
python字典如何添加元素
python writerow乱码怎么解决

[关闭]
~ ~