python - 拆分后与 Python 的缩进不一致

标签 python mysql split warnings indentation

正在编辑中,稍后有时会重新提交 正在编辑中,稍后有时会重新提交 正在编辑中,稍后有时会重新提交

最佳答案

这应该有效:

import re #Regex may be the easiest way to split that line

with open(infile) as in_f, open(outfile,'w') as out_f:
    f = (i for i in in_f if i.rstrip()) #iterate over non empty lines
    for line in f:
        _, k = line.split('\t', 1)
        x = re.findall(r'^1..100\t([+-])chr(\d+):(\d+)\.\.(\d+).+$',k)
        if not x:
            continue
        out_f.write(' '.join(x[0]) + '\n')

关于python - 拆分后与 Python 的缩进不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6673917/

相关文章:

python - 如何强制 scipy.optimize 中的 lesssq 函数优于每个数据点

python - 获取数据框中值的组合并实现一个函数

python - Django:如果没有初始数据则搜索函数

MYSQL - 重复

python - 使用 Python 正则表达式在字符之间拆分字符串

java - 无法使用 char 数组分割创建的字符串\n

python - 在 numpy (Python) 中相当于 Matlab 'ismember'?

重定向到 install.php 的 PHP 脚本

python - 我该如何过滤 django 和 MySQL 数据库中的两个字段?

python - 如何提取/拆分数据框中的列表列以分隔唯一的列?