- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 10 Creating and Modifying Text.ppt
* Demo eliza here. Where’s the temperature? The word “temperature” doesn’t really show up. But the temperature always follows the word “Currently”, and always comes before the “bdeg;/b” td img src=/shared-local/weather/images/ps.gif width=48 height=48 border=0font size=-2br/fontfont size=-1 face=Arial, Helvetica, sans-serifbCurrently/bbr Partly sunnybr font size=+254bdeg;/b/fontfont face=Arial, Helvetica, sans-serif size=+1F/font/font/td /tr We can use the same algorithm we’ve seen previously Grab the content out of a file in a big string. (We’ve saved the HTML page previously. Soon, we’ll see how to grab it directly.) Find the starting indicator (“Currently”) Find the ending indicator (“bdeg;”) Read the previous characters Finding the temperature def findTemperature(): weatherFile = getMediaPath(ajc-weather.html) file = open(weatherFile,rt) weather = file.read() file.close() # Find the Temperature curloc = weather.find(Currently) if curloc -1: # Now, find the bdeg; following the temp temploc = weather.find(bdeg;,curloc) tempstart = weather.rfind(,0,temploc) print Current temperature:,weather[tempstart+1:temploc] if curloc == -1: print They must have changed the page format -- cant find the temp Adding new capabilities: Modules What we need to do is to add capabilities to Python that we haven’t seen so far. We do this by importing external modules. A module is a file with a bunch of additional functions and objects defined within it. Some kind of module capability exists in virtually every programming language. By importing the module, we make the module’s capabilities available to our program. Literally, we are evaluating the module, as if we’d typed them into our file. Python’s Standard Library Python has an extensive library of modules that come with it. The Python standard library includes modules that allow us to access the Internet, deal with time, generate random numbers, and…access files in a directory. Accessing pieces
您可能关注的文档
- Based on the Iron (Fe) and Atherosclerosis Study (FeAST).ppt
- bbs-hz0752-net.ppt
- BEA Confidential..ppt
- Best Wish For You.ppt
- Better Ingredients.ppt
- Bio 402502Section II, Lecture 7.ppt
- Biochemistry.ppt
- BlackBerry 8707hTM.ppt
- BLAT – The BLAST-Like Alignment Tool.ppt
- BLOOD GLUCOSE MONITORING.ppt
- Chapter 10 Place andDevelopment ofChannel Systems.ppt
- Chapter 10 Warehousing Management.ppt
- Chapter 10Sales and Persuasive Messages.ppt
- Chapter 11. Gear Trains.PPT
- Chapter 13 Sense Organs and the Sensory Function of Nerv.ppt
- Chapter 2 Speech Sounds.ppt
- Chapter 21 Immunoprophylaxis and Immunotherapy.ppt
- Chapter 2Conservation of mass Illustration parts.ppt
- Chapter 3 Data Link Layer.ppt
- Chapter 3 Phonology.ppt
最近下载
- 02S701 砖砌化粪池图集.pdf VIP
- 文献检索与科技论文写作 课件全套 第1--9章 绪论、科技文献检索基础知识---科技论文的投稿.pdf VIP
- 中国数字经济现状及未来发展.docx VIP
- 常用起重索具、吊具计算.doc VIP
- 桥头跳车防治技术.pptx VIP
- 厨师安全教育培训考试题及答案.docx VIP
- 12.《总也倒不了的老屋》课件(共12张PPT).pptx VIP
- 施工安全隐患排查治理方案.docx VIP
- 全套课件-科技文献检索与论文写作..pptx VIP
- Python程序设计基础 课件全套 傅彬 项目1--10 Python语言及编程环境---正则表达式.pptx
文档评论(0)