- 浏览: 117827 次
- 性别:
- 来自: 武汉
文章分类
最新评论
"""Miscellaneous utility functions
This program is part of "Dive Into Python", a free Python book for
experienced programmers. Visit http://diveintopython.org/ for the
latest version.
"""
__author__ = "Mark Pilgrim (mark@diveintopython.org)"
__version__ = "$Revision: 1.3 $"
__date__ = "$Date: 2004/05/05 21:57:20 $"
__copyright__ = "Copyright (c) 2001 Mark Pilgrim"
__license__ = "Python"
def openAnything(source):
"""URI, filename, or string --> stream
This function lets you define parsers that take any input source
(URL, pathname to local or network file, or actual data as a string)
and deal with it in a uniform manner. Returned object is guaranteed
to have all the basic stdio read methods (read, readline, readlines).
Just .close() the object when you're done with it.
Examples:
>>> from xml.dom import minidom
>>> sock = openAnything("http://localhost/kant.xml")
>>> doc = minidom.parse(sock)
>>> sock.close()
>>> sock = openAnything("c:\\inetpub\\wwwroot\\kant.xml")
>>> doc = minidom.parse(sock)
>>> sock.close()
>>> sock = openAnything("<ref id='conjunction'><text>and</text><text>or</text></ref>")
>>> doc = minidom.parse(sock)
>>> sock.close()
"""
if hasattr(source, "read"):
#The arguments are an object and a string. The result is True
if the
string is the name of #one of the object's attributes, False
if not
#这个函数是检查read是否是source的一个属性
return source
if source == "-":
import sys
return sys.stdin
#若source是一个字符串“-”,则导入sys模块,并返回标准输入
# try to open with urllib (if source is http, ftp, or file URL)
import urllib
#导入urllib模块
try:
return urllib.urlopen(source)
#返回打开的url
#试着返回
except (IOError, OSError):
pass
# try to open with native open function (if source is pathname)
try:
return open(source)
except (IOError, OSError):
pass
# treat source as string
import StringIO
return StringIO.StringIO(str(source))
发表评论
-
一个完整的php项目示例
2009-05-19 13:30 1281<script>function StorePag ... -
一个简单的python代理服务器源码分析
2009-05-20 00:29 1418<script>function StorePag ... -
python起步
2009-05-21 00:15 585<script>function StorePag ... -
urllister.py源码分析
2009-05-22 00:08 1042<script>function StorePag ... -
fibonacci.py源代码分析
2009-05-22 23:24 612<script>function StorePag ... -
builddialectexamples.py源代码分析
2009-05-25 00:05 521<script>function StorePag ... -
piglatin.php源代码分析
2009-05-25 22:58 681<script>function StorePag ... -
plural.py源代码分析
2009-05-26 22:28 547<script>function StorePag ... -
regression.py源代码分析
2009-05-27 21:33 769<script>function StorePag ... -
apihelpertest.py源代码分析
2009-05-28 23:47 513<script>function StorePag ... -
argecho.py源代码分析
2009-05-30 00:44 594<script>function StorePag ... -
soundex.py源代码分析
2009-05-31 01:58 536<script>function StorePag ... -
plural1.py源代码分析
2009-05-31 22:27 585<script>function StorePag ... -
sum.py源代码分析
2009-06-03 00:14 716<script>function StorePag ... -
python打印变量的标识符、类型和值
2009-06-03 22:44 2110<script>function StorePag ... -
stringFormatting.py源代码分析
2009-06-04 23:49 485<script>function StorePag ... -
operator.py源代码分析
2009-06-05 23:12 539<script>function StorePag ... -
average.py源代码分析
2009-06-07 00:20 499<script>function StorePag ... -
square.py源代码分析
2009-06-08 00:05 591<script>function StorePag ... -
left.php源代码分析
2009-06-09 01:06 955<script>function StorePag ...
相关推荐
PDF.Toolbox.4.0.55.CRACK
nsct_toolbox.rar
DockerToolbox.exe国外开源遥控器技术使用于基本程序的
t4 toolbox for visual studio 2019
matlab-wavelet toolbox-提取自r2016a,下载后放到matlab目录下的toolbox中,并在预设目录中添加他和子目录,最后在预设-常规中点击更新工具箱路径缓存即可
Using the MATLAB PDE TOOLBOX.chmUsing the MATLAB PDE TOOLBOX.chm
wiley.ubuntu.linux.toolbox.1000.plus.commands.for.ubuntu.and.debian.power.users.nov.2007.pdf
MATLAB高阶谱分析信号处理工具箱(HOSA) Toolbox.rarMATLAB高阶谱分析信号处理工具箱(HOSA) Toolbox.rar
network_analyst_toolbox.chmnetwork_analyst_toolbox.chm
bioinformatics toolbox.pdf文档
rar修复工具破解补丁 recovery.toolbox.for.rar.v1.1.8.17-patch
演示程序和一些基本的函数svm_toolbox.rar演示程序和一些基本的函数svm_toolbox.rar演示程序和一些基本的函数svm_toolbox.rar
适合SVM初学者使用,matlab实现SVM算法进行分类 1.实验内容 (1)掌握支持向量机(SVM)的原理,核函数类型选择以及核参数选择原则等,并用malab的SVM函数求解各类分类问题实例。
The Linux Programmer’s Toolbox.pdf
MATLABLaydataToolbox-MATLAB-Laydata Toolbox.rar MATLAB-Laydata Toolbox.zip
Lynx Matlab Toolbox.zip
LIDC Matlab Toolbox.zip
Matlab Copula Toolbox.zip
MPO-Toolbox.zip,安装后,电脑看索尼相机所照的3D照片、影片用。
1、使用ArcMAP中的模型构建器提取流域,分为了两部分,第一部分(Hydrolog-dir-acc)为前期的流向,流量提取,主要是做为后续不同流量阈值的基础数据,第二部分(Hydrolog)为水文分析,得到水系和集水区(流域)的...