我有以下脚本:
你知道吗测试.py地址:
import sys
try:
import random
print random.random()
except:
print sys.exc_info()[0]
你知道吗运行.sh地址:
python "test.py" >> "test_file" ;
在我的linux服务器上运行以下命令时:
[saray@compute-0-15 ~]$ nohup ./run.sh &
测试文件包括预期的随机数:
[saray@compute-0-15 ~]$ cat test_file
0.923051769631
但是,当使用以下命令远程运行同一命令时:
[saray@blob-cs ~]$ ssh "compute-0-15" 'nohup ./run.sh > /dev/null 2>&1 &'
python无法上传随机包!!你知道吗
[saray@compute-0-15 ~]$ cat test_file
exceptions.SyntaxError
怎么了?你知道吗
您的远程计算机正在运行不同的Python版本python3。你知道吗
在python3中,
print
语句被替换为print
函数,代码抛出语法错误。你知道吗解决方法是要么用Python 2远程运行代码,要么使代码与Python 2和Python 3兼容:
相关问题 更多 >
编程相关推荐