【发布时间】:2019-05-08 09:37:03
【问题描述】:
背景。计算机科学四年级学生。一年级蟒蛇。
问题:我在两个地方运行程序,Pycharm (IDE) 和使用终端的外部服务器。相同python的输出 在这两个东西上运行时文件是不同的。我需要它 相同,最好是正确的。 (是的,python 和 fasta 文件 在终端和 Pycharm 上是一样的)。
pycharm 和终端上的文件。
Pycharm 文件:
- chromosome9.fa
- Window.py
- 运行命令:python Window.py colour9.fa
终端文件
- chrom9.fa
- Window.py
- 运行命令:python Window.py chrom9.fa
Pycharm 文件的输出
There are 1255728 CpG pairs in this sequence.
[(63385200, 63385679), (64711680, 64712169), (65825370, 65825849), (131739850, 131740259), (134326260, 134326859)]
[(1092400, 1092839), (1366440, 1366849), (1549650, 1550099), (4068100, 4068849), (4326450, 4327169), (9216770, 9217449), (12647450, 12648029), (14136430, 14136909), (15126110, 15126569)
, (29073770, 29074689), (39586690, 39587139), (73198340, 73198929), (74377730, 74378379), (75009180, 75009779), (75341380, 75341889), (99970290, 99970769), (103436370, 103436809)]
getting average CpGIsland length for + strand
Average length: 491.0
getting average CpGIsland length for - strand
Average length: 564.2941176470588
终端程序的输出
('There are', 1255728, 'CpG pairs in this sequence.')
[]
[]
getting average CpGIsland length for + strand
Average length : 0
getting average CpGIsland length for - strand
Average length : 0
打印语句
print("There are",len(CG_indices),"CpG pairs in this sequence.")
两者的打印效果也不同,但我目前不在乎。
有人知道发生了什么吗?
【问题讨论】:
-
首先猜测是 Pycharm 使用的解释器与终端使用的解释器不同
-
如果没有代码的相关部分,第二次猜测基本上是不可能的。看看这里如何创建minimal reproducible example。
-
提示服务器上的 Python 2 与 IDE 中的 Python 3 可能是答案:在 Python 2 中执行
print(something, something_else)时,会打印一个元组,而在 Python 3 中需要括号,因为 @ 987654326@ 是函数,不再是语句。 -
also prints different for both but I don't care about that currently.你应该关心。这意味着 PyCharm 在 Python3.x 上运行,而在 Python 2.x 上运行服务器。这些非常不兼容,很可能是您问题的根源。