【发布时间】:2019-01-14 09:42:20
【问题描述】:
if ( ! exists $tRHash{$tR} ) {
if ( $start < $end ) {
$pS = $start - 41;
$pE = $end + 40;
print "$chr\t$pS\t$pE\tpre-$tR\t0\t$st\n";
}
else {
$pS = $end - 40;
$pE = $start + 40;
print "$chr\t$pS\t$pE\tpre-$tR\t0\t$st\n";
}
$tRHash{$tR} = $tR;
}
如何在 Python 中做到这一点,尤其是哈希部分?我已经执行了if 语句,但我正在努力处理 Perl 中的输出格式。
pS, pE = zip(*[(n - 41, m + 40) if n < m else (n + 40, m - 40)
for n, m in zip(start, end)])
【问题讨论】:
-
您展示的 Python 与 Perl 代码的工作方式不同。当 Perl 中的简单
ifelse就足够时,为什么还要使用花哨的列表解析?
标签: python-2.7 perl hash