博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Applications of Python
阅读量:4360 次
发布时间:2019-06-07

本文共 1382 字,大约阅读时间需要 4 分钟。

import xml.dom.minidomimport osimport sysimport zipfileimport shutilimport datetimefrom os import pathdef main():    #working with xml    doc=xml.dom.minidom.parse("samplexml.xml");    print doc.nodeName    print doc.childNodes    print doc.firstChild.tagName    skills = doc.getElementsByTagName("skill")    print("%d skill " %  skills.length)    counter = 0    for skill in skills:        counter +=1        print "Skill # ",counter,"-",skill.getAttribute("name")    newSkill=doc.createElement("skill")    newSkill.setAttribute("name","JavaScript")    doc.firstChild.appendChild(newSkill)    skills = doc.getElementsByTagName("skill")    print ("%d Skill  " % skills.length)    for skill in skills:        print skill.getAttribute("name")    xmlfile = "samplexml.xml"    fh = open(xmlfile)    counter = 0    for line in fh:        counter +=1        if line.startswith("
1 : print "there are " ,len(sys.argv) -1 ,'arguments' for arg in sys.argv[1:]: print argelse:print "there are no argument"# checking host platformprint sys.platform # win32if sys.platform=="win32": import ntpath pathmodule = ntpathprint pathmodule # out put
#redirect outputold = sys.stdoutsys.stdout=open("output.txt",'w')print "this file should be print into file output.txt"sys.stdout=oldprint "come back "

转载于:https://www.cnblogs.com/TendToBigData/p/10501251.html

你可能感兴趣的文章
【转】Eclipse和PyDev搭建完美Python开发环境(Ubuntu篇)
查看>>
redis安装和配置
查看>>
2016424王启元 Exp5 msf基础应用
查看>>
Differences between page and segment
查看>>
Jdk与Tomcat配置与安装
查看>>
关于一个Java web与JFrame的深度结合
查看>>
VB连数据库conn.open的参数
查看>>
《信息安全系统设计基础》实验三
查看>>
SpringBoot Docs
查看>>
解决sublime text 2总是在新窗口中打开文件(标签中打开)
查看>>
VUE AntDesign DatePicker设置默认显示当前日期
查看>>
WIN32窗口模板
查看>>
859. Buddy Strings - LeetCode
查看>>
[置顶] 关键字弹出动画
查看>>
支付宝api指南
查看>>
二叉树的广度优先遍历、深度优先遍历的递归和非递归实现方式
查看>>
docker-compose部署kafka
查看>>
IOS中NSUserDefaults的用法(轻量级本地数据存储)
查看>>
cms项目技术心得!
查看>>
Django模板系统
查看>>