zoukankan      html  css  js  c++  java
  • 一封没有发出的求救信

    同样的程序在Win下能跑,在Linux下就会出错
    以下为错误信息:

    Traceback (most recent call last):
    File "/root/cron/send.py", line 27, in <module>
    send()
    File "/root/cron/send.py", line 23, in send
    message_client(p, txt_message)
    File "/root/cron/send.py", line 10, in message_client
    proxy = WSDL.Proxy('http://webservice.dodoca.com:8080/NOSmsPlatform/services/BusinessService?wsdl')
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/WSDL.py", line 67, in __init__
    self.wsdl = reader.loadFromString(str(wsdlsource))
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/wstools/WSDLTools.py", line 47, in loadFromString
    return self.loadFromStream(StringIO(data))
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/wstools/WSDLTools.py", line 28, in loadFromStream
    document = DOM.loadDocument(stream)
    File "/opt/python/lib/python2.5/site-packages/SOAPpy/wstools/Utility.py", line 602, in loadDocument
    return xml.dom.minidom.parse(data)
    File "/opt/python/lib/python2.5/xml/dom/minidom.py", line 1915, in parse
    return expatbuilder.parse(file)
    File "/opt/python/lib/python2.5/xml/dom/expatbuilder.py", line 928, in parse
    result = builder.parseFile(file)
    File "/opt/python/lib/python2.5/xml/dom/expatbuilder.py", line 207, in parseFile
    parser.Parse(buffer, 0)
    xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 5

    以下为简单的代码:

    #!/usr/bin/env python
    #
    coding=utf-8

    from SOAPpy import WSDL

    def message_client(dest_mobile='1380013800', msg=''):
    account = '*******'
    password = '******'
    proxy = WSDL.Proxy('http://webservice.dodoca.com:8080/NOSmsPlatform/services/BusinessService?wsdl')
    index = proxy.sendBatchMessage(account, password, dest_mobile, msg)
    return index

    def send():
    fp = file('phone.txt')
    phone_list = [p for p in fp.read().split(';') if (len(p) == 11)]
    fp.close()

    txt_message = u"hello"

    for p in set(phone_list):
    message_client(p, txt_message)
    print p

    if __name__ == '__main__':
    send()


    使用的库有SOAPpy-0.12.0,fpconst-0.7.2,两个平台下都是安装的同一版本,
    写到这里我才想到可能是Python的版本不一样,遇到这种问题,直觉上的解决思路应该是比较两个平台下所有用到的语言版本,库的版本的不同。结果一查,Win下的Python是2.5.2,Linux下Python的版本是2.5.4,把Linux下的Python换成2.5.2,程序运行正确。

    需要这种问题,我居然会觉得毫无解决办法,看来我的思维能力还有待大大的提高。

  • 相关阅读:
    用Live Writers发布Blog
    ScribeFire
    再再上传一个图片
    jQuery页面加载初始化常用的三种方法
    JS 20200101T00:00:00.000000Z 日期格式转换、Sun Jul 04 2021 00:00:00 GMT+0800 (中国标准时间)转20210704 00:00
    vue 组件传值 props $emit $event
    jquery或js如何判断一个层是显示还是隐藏
    js合并俩个数组的三种方法
    uniapp生命周期
    SVN版本冲突
  • 原文地址:https://www.cnblogs.com/crafter/p/2262941.html
Copyright © 2011-2022 走看看