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,程序运行正确。

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

  • 相关阅读:
    9.堆排序
    8.全排列
    37.微信跳一跳辅助开发(C语言+EasyX)
    7.图形化实现快速排序法
    codeforces 632A A. Grandma Laura and Apples(暴力)
    codeforces 633D D. Fibonacci-ish(dfs+暴力+map)
    codeforces 633B B. A Trivial Problem(数论)
    codeforces 633A A. Ebony and Ivory(暴力)
    codeforces 622B B. The Time
    codeforces 622D D. Optimal Number Permutation(找规律)
  • 原文地址:https://www.cnblogs.com/crafter/p/2262941.html
Copyright © 2011-2022 走看看