我就在这里
分类: Python/Ruby
2013-02-19 08:18:21
调用
'''
Created on 2013-2-19
@author: lvxinzhi
'''
import XmlBuild
import Send
if __name__ == '__main__':
xml = XmlBuild.XmlBuild('ClientFileManagerCommand', 'downloadfile')
xml.addParameter('filename', 'update_tmp.ini')
xml.commandname = 'ClientFileManagerCommand.downloadfile'
print xml.getXml().toxml()
#xml.saveas('c:\\client.ClientFileManagerCommand.downloadfile.xml')
Traceback (most recent call last):
File "D:\workSpace\python\Client\src\Main.py", line 10, in
xml = XmlBuild('ClientFileManagerCommand', 'downloadfile')
TypeError: 'module' object is not callable
原因分析:
Python导入模块的方法有两种:import module 和 from module import,区别是前者所有导入的东西使用时需加上模块名的限定,而后者不要。
正确的代码:
import XmlBuild
import Send
if __name__ == '__main__':
xml = XmlBuild.XmlBuild('ClientFileManagerCommand', 'downloadfile')
或
from XmlBuild import *
import Send
if __name__ == '__main__':
xml = XmlBuild('ClientFileManagerCommand', 'downloadfile')