Python Web-第五周-Web Services and XML(Using Python to Access Web Data)
1.Web Service Overview
1.Data on the Web
Python Dictionary 和 Java HashMap间需要建立一个桥梁,可以用XML或是JSON
2.XML
3.JSON: JavaScript Object Notation
2.Interview:Roy Fielding - Understanding the REST Architecture
1.知乎上lvony关于REST结构的概括
3.eXtensible MarkUp Language - XML
1.XML 的诞生
XML诞生的目的就是帮助各个信息系统间交换指定结构的数据
docx、pptx 中的x都代表XML,XML用于描述其文档结构
2.XML元素
3.XML举列
XML的各种属性不同于HTML,是可以根据需要自行设置的
XML基本就是个树结构,像是文件夹目录/a/b/、/a/c/d
4.XML Schema
1.XML Schema定义
2.XML Schema作用
5.Parsing XML in Python
1.XML实例
import xml.etree.ElementTreeas ET
data ='''
<person>
<name>Chuck</name>
<phone type="intl">
+1 734 303 4456
</phone>
<email hide="yes"/>
</person>'''
tree = ET.fromstring(data)
print'Phone:',tree.find('phone').text
print'Phone Type:',tree.find('phone').get('type')
print'Attr:',tree.find('email').get('hide')
import xml.etree.ElementTreeas ET
input ='''
<stuff>
<users>
<user x="2">
<id>001</id>
<name>Chuck</name>
</user>
<user x="7">
<id>009</id>
<name>Brent</name>
</user>
</users>
</stuff>'''
stuff = ET.fromstring(input)
lst = stuff.findall('users/user')#return a list
print'User count:', len(lst)
for item in lst:
print'Name', item.find('name').text
print'Id', item.find('id').text
print'Attribute', item.get("x")
Words:
Python Web-第五周-Web Services and XML(Using Python to Access Web Data)的更多相关文章
- 初学 Python(十五)——装饰器
初学 Python(十五)--装饰器 初学 Python,主要整理一些学习到的知识点,这次是生成器. #-*- coding:utf-8 -*- import functools def curren ...
- 《Using Python to Access Web Data》 Week5 Web Services and XML 课堂笔记
Coursera课程<Using Python to Access Web Data> 密歇根大学 Week5 Web Services and XML 13.1 Data on the ...
- The Python web services developer: XML-RPC for Python
原文地址:http://www.ibm.com/developerworks/webservices/library/ws-pyth10/index.html 摘要:概括地说,您可以将 XML-RPC ...
- Python Web-第二周-正则表达式(Using Python to Access Web Data)
0.课程地址与说明 1.课程地址:https://www.coursera.org/learn/python-network-data/home/welcome 2.课程全名:Using Python ...
- java web 学习五(servlet开发1)
一.Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向 ...
- 五张图概括 什么是 ASP 、 ASP.NET (Web Pages,Web Forms ,MVC )
当你看懂下面这五张图,我相信你对于学习.NET Web开发路线将不陌生! 来源: http://www.w3 ...
- 【Python学习笔记】Coursera课程《Using Python to Access Web Data》 密歇根大学 Charles Severance——Week6 JSON and the REST Architecture课堂笔记
Coursera课程<Using Python to Access Web Data> 密歇根大学 Week6 JSON and the REST Architecture 13.5 Ja ...
- 【Python学习笔记】Coursera课程《Using Python to Access Web Data 》 密歇根大学 Charles Severance——Week2 Regular Expressions课堂笔记
Coursera课程<Using Python to Access Web Data > 密歇根大学 Charles Severance Week2 Regular Expressions ...
- 《Using Python to Access Web Data》Week4 Programs that Surf the Web 课堂笔记
Coursera课程<Using Python to Access Web Data> 密歇根大学 Week4 Programs that Surf the Web 12.3 Unicod ...
随机推荐
- c语言中的#ifdef和#ifndef
#include "stdio.h"#include "conio.h"#define MAX#define MAXIMUM(x,y) (x>y)?x:y ...
- CSS学习(一)---使用CSS的四种方式
1. 行内样式 例: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- Java集合中的Map接口
jdk1.8.0_144 Map是Java三种集合中的一种位于java.util包中,Map作为一个接口存在定义了这种数据结构的一些基础操作,它的最终实现类有很多:HashMap.TreeMap.So ...
- python多版本以及各种包管理
python多版本以及各种包管理 python 包管理 各个版本 python版本管理 由于Python有2.x和3.x两个大的版本,而且每一个工程建立所用的各种包的版本也不尽相同(如flask1.x ...
- RHEL6误安装RHEL7的包导致glibc被升级后系统崩溃处理方法
RHEL6误使用了RHEL7的光盘源,安装了某个RPM包之后,导致glibc被升级,进而导致系统崩溃. [root@rhel65 ~]# yum install ftp Loaded plugin ...
- lnmp HTTP ERROR 500
http://www.cnblogs.com/thrillerz/p/4725409.html
- 浏览器的 bfcache 特性
一.bfcache 基本概念 现代浏览器在根据历史记录进行前进/后退操作时,会启用缓存机制,名为"bfcache"(back-forward cache,往返缓存),它使页面导航非 ...
- hdu4825 01字典树+贪心
从高位向低位构造字典树,因为高位得到的数更大. AC代码: #include<cstdio> using namespace std; typedef long long LL; cons ...
- Appium适配Android7.0以上版本
Appium适配Android7.0以上版本 测试机型: 华为荣耀V9 安卓版本: Android7.0 appium版本: 1.65 说明: 公司新采购了一批安卓机器,拿了其中一台华为荣耀V9跑之前 ...
- shell脚本——mysql
很期待,学习shell脚本,减少重复工作 自动安装配置mysql脚本: #/bin/bash LOG_FILE=/home/hadoop1/log/installmysql.log function ...