------------------------------------------------------------------------------------- Suds (https://fedorahosted.org/suds/) version: 0.3.9 (beta) build: R658-20100210
Service (ndfdXML) tns="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl" Prefixes (2)
ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
ns1 = "http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd" Ports (1):
(ndfdXMLPort)
Methods (12):
***CornerPoints***(ns1:sectorType sector,)
***GmlLatLonList***(ns1:listLatLonType listLatLon, xs:dateTime requestedTime, ns1:featureTypeType featureType, ns1:weatherParametersType weatherParameters,)
***GmlTimeSeries***(ns1:listLatLonType listLatLon, xs:dateTime startTime, xs:dateTime endTime, ns1:compTypeType compType, ns1:featureTypeType featureType, xs:string propertyName,)
***LatLonListCityNames***(ns1:displayLevelType displayLevel,)
***LatLonListLine***(xs:decimal endPoint1Lat, xs:decimal endPoint1Lon, xs:decimal endPoint2Lat, xs:decimal endPoint2Lon,)
***LatLonListSquare***(xs:decimal centerPointLat, xs:decimal centerPointLon, xs:decimal distanceLat, xs:decimal distanceLon, xs:decimal resolution,)
***LatLonListSubgrid***(xs:decimal lowerLeftLatitude, xs:decimal lowerLeftLongitude, xs:decimal upperRightLatitude, xs:decimal upperRightLongitude, xs:decimal resolution,)
***LatLonListZipCode***(ns1:zipCodeListType zipCodeList,)
**NDFDgen**(xs:decimal latitude, xs:decimal longitude, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters,)
***NDFDgenByDay***(xs:decimal latitude, xs:decimal longitude, xs:date startDate, xs:integer numDays, ns1:formatType format,)
***NDFDgenByDayLatLonList***(ns1:listLatLonType listLatLon, xs:date startDate, xs:integer numDays, ns1:formatType format,)
***NDFDgenLatLonList***(ns1:listLatLonType listLatLon, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters,)
Types (60):
ns0:Array
ns0:ENTITIES
ns0:ENTITY
ns0:ID
ns0:IDREF
ns0:IDREFS
ns0:NCName
ns0:NMTOKEN
ns0:NMTOKENS
ns0:NOTATION
ns0:Name
ns0:QName
ns0:Struct
ns0:anyURI
ns0:arrayCoordinate
ns0:base64
ns0:base64Binary
ns0:boolean
ns0:byte
ns1:compTypeType
ns0:date
ns0:dateTime
ns0:decimal
ns1:displayLevelType
ns0:double
ns0:duration
ns1:featureTypeType
ns0:float
ns1:formatType
ns0:gDay
ns0:gMonth
ns0:gMonthDay
ns0:gYear
ns0:gYearMonth
ns0:hexBinary
ns0:int
ns0:integer
ns0:language
ns1:latLonPairType
ns1:listCityNamesType
ns1:listLatLonType
ns0:long
ns0:negativeInteger
ns0:nonNegativeInteger
ns0:nonPositiveInteger
ns0:normalizedString
ns0:positiveInteger
ns1:productType
ns1:sectorType
ns0:short
ns0:string
ns0:time
ns0:token
ns0:unsignedByte
ns0:unsignedInt
ns0:unsignedLong
ns0:unsignedShort
ns1:weatherParametersType
ns1:zipCodeListType
ns1:zipCodeType
-------------------------------------------------------------------------------------------
回答
import re
text='''Service (ndfdXML) tns="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl" Prefixes (2) ns0 = "http://schemas.xmlsoap.org/soap/encoding/" ns1 = "http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd" Ports (1): (ndfdXMLPort) Methods (12): CornerPoints(ns1:sectorType sector,) GmlLatLonList(ns1:listLatLonType listLatLon, xs:dateTime requestedTime, ns1:featureTypeType featureType, ns1:weatherParametersType weatherParameters,) GmlTimeSeries(ns1:listLatLonType listLatLon, xs:dateTime startTime, xs:dateTime endTime, ns1:compTypeType compType, ns1:featureTypeType featureType, xs:string propertyName,) LatLonListCityNames(ns1:displayLevelType displayLevel,) LatLonListLine(xs:decimal endPoint1Lat, xs:decimal endPoint1Lon, xs:decimal endPoint2Lat, xs:decimal endPoint2Lon,) LatLonListSquare(xs:decimal centerPointLat, xs:decimal centerPointLon, xs:decimal distanceLat, xs:decimal distanceLon, xs:decimal resolution,) LatLonListSubgrid(xs:decimal lowerLeftLatitude, xs:decimal lowerLeftLongitude, xs:decimal upperRightLatitude, xs:decimal upperRightLongitude, xs:decimal resolution,) LatLonListZipCode(ns1:zipCodeListType zipCodeList,) NDFDgen(xs:decimal latitude, xs:decimal longitude, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters,) NDFDgenByDay(xs:decimal latitude, xs:decimal longitude, xs:date startDate, xs:integer numDays, ns1:formatType format,) NDFDgenByDayLatLonList(ns1:listLatLonType listLatLon, xs:date startDate, xs:integer numDays, ns1:formatType format,) NDFDgenLatLonList(ns1:listLatLonType listLatLon, ns1:productType product, xs:dateTime startTime, xs:dateTime endTime, ns1:weatherParametersType weatherParameters,) Types (60): ns0:Array ns0:ENTITIES ns0:ENTITY ns0:ID ns0:IDREF ns0:IDREFS ns0:NCName ns0:NMTOKEN ns0:NMTOKENS ns0:NOTATION ns0:Name ns0:QName ns0:Struct ns0:anyURI ns0:arrayCoordinate ns0:base64 ns0:base64Binary ns0:boolean ns0:byte ns1:compTypeType ns0:date ns0:dateTime ns0:decimal ns1:displayLevelType ns0:double ns0:duration ns1:featureTypeType ns0:float ns1:formatType ns0:gDay ns0:gMonth ns0:gMonthDay ns0:gYear ns0:gYearMonth ns0:hexBinary ns0:int ns0:integer ns0:language ns1:latLonPairType ns1:listCityNamesType ns1:listLatLonType ns0:long ns0:negativeInteger ns0:nonNegativeInteger ns0:nonPositiveInteger ns0:normalizedString ns0:positiveInteger ns1:productType ns1:sectorType ns0:short ns0:string ns0:time ns0:token ns0:unsignedByte ns0:unsignedInt ns0:unsignedLong ns0:unsignedShort ns1:weatherParametersType ns1:zipCodeListType'''
for match in re.findall(r"[a-zA-Z]+?\s*\([a-z]*?[0-9]*?:",text):
print match.split("(")[0]
你想要一个正则表达式来找到它们或每一个吗?你需要返回哪些数据(我假设()和对象名称的内容)?
从你有什么猜测,我认为这样的事情会工作:
((CornerPoints|LatLonListZipCode|other|names)\(.*\)))
将匹配在上半场的一个名称,然后(data)
组后(您可能要使它非贪婪)。
如果您使用更多信息编辑问题或评论,我会编辑答案。
在这里解析泡沫的输出没有什么意义。有API的方法来做到这一点。至少打印到控制台的结果有一种可以通过Python迭代的数据结构。 – 2011-04-06 02:41:30
我可以看到一个正则表达式是一个抓取一个对象的快速和肮脏的方法,但它肯定不是最好的。需要更多的信息,为什么TheDodo想要使用正则表达式和目标是什么,也许有一些愚蠢的要求? – ssube 2011-04-06 02:44:29
他想要一个正则表达式,因为他不知道更好 – 2011-04-06 02:48:22
@peachykeen:是的,它需要是非贪婪的,否则。*会一直跑到最后'''字符串中。您还需要匹配组,最好命名为,以便引用您匹配的内容:
/(?P<key>name1|name2|...)(?P<value>\(.*?\))/
@RestRisiko:我想要做的是:我有这个文件包含此文本(作为Suds客户端响应:))在txt文件中。现在我想要做的就是只提取由WebService提供的“方法”名称。稍后将这些所有方法名称都写入不同的文本文件。 – TheDodo 2011-04-06 04:33:23
- 1. Love2d无法在同一目录中找到字体文件
- 2. Gitweb无法找到存储库“找不到这样的项目”
- 3. Android studio无法在项目文件中找到爆炸目录
- 4. MySQL REGEXP找到一个词
- 5. 无法在Maven项目中找到类
- 6. 我无法写入添加到项目中的txt文件
- 7. 目录中的文件无法找到
- 8. 无法找到项目文件夹中的JSON文件
- 9. JavaFX:Maven项目无法找到css文件,没有找到Maven css文件
- 10. R Markdown无法在一个项目中找到.bib文件,同时在另一个项目中正常工作
- 11. 无法找到React Native项目上的意外标记
- 12. DLL无法在项目文件夹中找到
- 13. Wp8无法在项目中找到csv文件
- 14. 我不能让netbeans找到我在同一个目录下的txt文件... java.io.FileNotFoundException
- 15. Ruby - 无法在txt文件中找到字符串
- 16. AndroidStudio无法同步Gradle项目,无法找到目标Google Inc
- 17. 项目文件未找到
- 18. TObjectList找到一个项目
- 19. Tomcat7找不到我的txt文件
- 20. 我无法找到我的php.ini文件
- 21. 遇到错误无法找到源文件到我的Windows CE的项目
- 22. 找到每一个项目,最昂贵的一些条件
- 23. QTKit无法找到文件或目录
- 24. 为什么NSFileManager无法找到这些png文件?
- 25. nginx无法找到我的文件在一个位置块
- 26. 在一个目录中找到'all'文件,并非找到所有文件
- 27. React-Native无法找到构建中的主要项目文件
- 28. ASP.NET项目中的AIML Bot无法找到CONFIG文件?
- 29. 编译文件时无法在ubuntu上找到一些boost库
- 30. 查看无法找到另一个项目中的模型类
请正确格式化您的代码!除此之外:提供你迄今为止所尝试的信息......我们不能猜测你迄今为止所做的努力,从现有的东西中获得帮助比从头开始获得帮助要容易得多。 – 2011-04-06 02:39:01
除此之外呢?你为什么要解析* this *输出? Suds提供了反思相关结果的足够方法。你的特定用例是什么? – 2011-04-06 02:40:29
欢迎来到StackOverflow!我已将格式化问题的文本给你。你能否更详细地解释你遇到的实际问题?有关提问问题的更多提示,请查阅[FAQ](http://stackoverflow.com/faq)。 – Johnsyweb 2011-04-06 03:30:04