《Head First Programming》---python 3_函数
2014-04-22 20:36
495 查看
函数
import urllib.request import time def get_price(): page = urllib.request.urlopen("http://www.laofengxiang.com/index.php") text = page.read().decode("utf8") #print(text) where = text.find("铂金: ") #print(where) start_of_price = where + 4; #print(start_of_price) end_of_price = start_of_price + 3 #print(end_of_price) #print(text[start_of_price:end_of_price]) return (text[start_of_price:end_of_price]) price_now = input("Do you want to see the price now (Y/N) ? ") if price_now == "Y": print(get_price()) else: price = float(get_price()) while price > 499.9: time.sleep(3600) #每隔1小时刷新一次 price = float(get_price()) print("Price is ", price, "元/克") print("Buy for my lover!")
相关文章推荐
- Mootools 1.2教程 函数
- autoit InputBox 函数
- 文件遍历排序函数
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页
- ASP下经常用的字符串等函数参考资料
- asp Chr 函数 数字转字母的方法
- 探索PowerShell(十一)函数介绍
- vbscript LoadPicture函数使用方法与漏洞利用
- vbs 中调用shell.application 简单函数
- Asp函数介紹(37个常用函数)第1/2页
- phplib中的一些基本语法和函数
- 从汇编看c++中函数里面的static关键字的使用说明
- 图象函数中的中文显示
- 一步一步学习PHP(4) php 函数 补充2
- 一个目录遍历函数
- thinkphp3.0 模板中函数的使用
- php下过滤HTML代码的函数
- 一些使用频率比较高的php函数
- C# javaScript函数的相互调用
- ASP.NET编程中经常用到的27个函数集