python脚本语言确实很强大,但是在更新版本的时候却出现不向下兼容问题,这给我们的开发和升级带来诸多的不便,下面将我在更新版本之后遇到的几个问题记录如下:

    最初我是在python低版本中进行的程序开发,现在进行python版本的升级,我的虚拟机采用linux操作系统,自带的python版本是2.4.3,我的windows操作系统安装的是最新的3.2.2版本。

    1、“inconsistent use of tabs and spaces in indentation”这个错误让人很抓狂,设置都没有问题,可就是报这个错误,最后在新版本中重新写了一遍,却又没有发现这个问题,查了资料说是由空格和tab键的问题。

    2、socket.error: (11, 'Resource temporarily unavailable');socket文件在编译时报这个错误,查了11是EWOULDBLOCK,非阻塞模式下产生的中断,看了下代码,我前面是有设置s.setblocking(False),查文档,原来这个非阻塞相当于设置了超时时间为0,所以会报这个错误,所以在设置非阻塞模式时,我们最好显式的声明一下其超时时间。

   

socket.setblocking(flag)

    Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to
 non-blocking, else to blocking mode.

    This method is a shorthand for certain settimeout() calls:

        sock.setblocking(True) is equivalent to sock.settimeout(None)
        sock.setblocking(False) is equivalent to sock.settimeout(0.0) 
    



此文章由指尖极客原创,转载请指出其作者和出处!http://blog.csdn.net/wenchao126

GitHub 加速计划 / li / linux-dash
12
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐