【问题标题】:Sublime Text run python works on mac but not on windows 8Sublime Text run python 适用于 mac 但不适用于 windows 8
【发布时间】:2012-10-19 11:11:46
【问题描述】:

在我的 mac 上使用 sublime text:

# farenhiet to celcius
def farenheit2celcious (farenheit):
celcius = (5 / 9) * (farenheit - 32)
return celcius

#test
c1 = farenheit2celcious(32)
print c1

在控制台中给出 0

在 Windows 中,在崇高的文本中,我得到了

打印 c1 ^ SyntaxError:无效的语法 [0.1s 完成,退出码 1]

有什么想法吗?行尾?文件是不同计算机从 Dropbox 访问的相同文件。两种环境都有 sublime text 2,可能安装了不同的包

【问题讨论】:

    标签: python sublimetext


    【解决方案1】:

    如果你在 windows 上安装了 python 3,那将是一个问题。我假设 MAC 上的 python 是 python2.x 而 windows 上的是 3.x

    在python 3中,print是一个函数,所以应该是print(c1)

    您可以通过以下方式检查python版本:

    1. 在 Mac 上的控制台输入 python 即可看到版本

    2. 在windows上打开IDLE,看看打印的是什么版本

    【讨论】:

    • 是的,就是这样。我改用 print (c1) 来测试它并在我的 windows 盒子上运行它。所以我现在将在 Windows 上将环境更改为 2x 以保持一致性。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 2016-11-07
    • 1970-01-01
    相关资源
    最近更新 更多