当我在Pycharm Community 2017.1.1中运行它时,它会执行两次
def site():
while True:
site = input("Which datacenter are you putting this in? (One at a time): ")
if site == 'ASH' or site == 'Ashburn' or site == 'ASHBURN':
core_ip = 'y.y.y.y'
break
elif site == 'CLT' or site == 'Charlotte' or site == 'CHARLOTTE':
core_ip = 'x.x.x.x'
break
else:
print ("That can't be it. Sorry, maybe you mistyped?")
return core_ip
print (site())
输出:
$ python3.5 site.py
Which datacenter are you putting this in? (One at a time): ASH
x.x.x.x
Which datacenter are you putting this in? (One at a time): CLT
y.y.y.y
但如果我从CLI运行它,它会完美运行
答案 0 :(得分:0)
已在评论中解决
所以,有几件事:@zmo - 好建议。我实现了解决命名问题,我将函数更改为site_ip。然后我删除了sites.py文件并将其重建为find_core_ip.py,现在它可以工作了。 - 史蒂夫B