读书人

同一段python代码在windows下能运行

发布时间: 2012-04-12 15:46:35 作者: rapoo

同一段python代码在windows下能运行,在ubuntu下不行,socket相关
代码如下:
import socket
def main():
host=socket.gethostname()
print host
if __name__ == '__main__':
main()
windows下正常运行,但是在ubuntu下显示AttributeError: 'module' object has no attribute 'gethostname'
这是为什么

[解决办法]
python版本不一致

读书人网 >perl python

热点推荐