[英]My python code runs a few times but as soon as I close my computer or do something else, it doesn't run again
Running this code a few times presents no issues. 几次运行此代码不会出现问题。 Upon attempting to show a friend, it doesn't work.
尝试向朋友显示时,此操作无效。 It just hangs after the input.
它只是在输入后挂起。 It's worked quite a few times before but never again unfortunately.
它已经工作了好几次,但不幸的是再也没有。
I've tried rewriting the code in brackets, rewriting the code to a local directory instead of the Google Drive folder I have and I've even tried rewriting from scratch in regular notepad. 我尝试将代码重写在方括号中,将代码重写到本地目录而不是我拥有的Google Drive文件夹中,甚至尝试在常规记事本中从头开始重写。 All this was tried in case some sort of encoding issue had occured.
如果发生某种编码问题,请尝试所有这些操作。 No such luck.
没有这种运气。 I figure something is wrong with the interpreter but I'm not sure how to remedy the situation.
我认为口译员出了点问题,但是我不确定如何解决这种情况。
def bin2dec():
bin = []
a = int(input("What number are you converting to binary?: "))
while a > 0:
if a % 2 == 0:
bin.insert(0, 0)
a = a/2
elif a % 2 == 1:
bin.insert(0, 1)
a = a/2-0.5
else:
#repetition
print("Your binary equivalent is:", bin)
repeat = input("Would you like to convert another binary number?: ")
if repeat == "yes":
bin2dec()
bin2dec()
Oh....welp. 哦。。。 It seems the problem was actually that I somehow installed two versions of pythons and I guess they had been interfering with each other.
看来问题出在实际上我以某种方式安装了两个版本的python,我想它们一直在互相干扰。 Reason I'm not deleting this Q is because I'm sure I'm not the only one who's made this mistake.
我之所以不删除此问题,是因为我确定不是唯一一个犯此错误的人。 However, others have probably made this mistake in an effort to ensure compatibility between versions.
但是,其他人可能在确保版本之间兼容性方面犯了这个错误。 Bad idea.
馊主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.