摘要: 【43】查天气1天气网的3个接口不可用百度 :天气网 接口【44】查天气2两个新模块1,urllib22.jsonimport urllib2web=urllib2.urlopen('http://www.baidu.com')content=web.read();f=file('baidu.html','w')f.write(content)f.close()解决中文问题和城市代码问题用了大半天中文问题的解决方法:在代码和城市代码py文件中开头部分都加上# -*- coding: cp936 -*-城市代码部分用excel和word完成城市代码 阅读全文
posted @ 2014-04-02 19:33 kaliu 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 【Python第31课到42课】【31】读文件f=file('data.txt')data=f.read()print dataf.close其他用法data.txt中存的内容是hi my name is mikehelloworld!当运行f=file('data.txt')data=f.readlines() #把内容按行读取至一个list中 ,所有内容都读出来了。print dataf.close结果['hi my name is mike\n', 'helloworld!']当运行f=file('data.txt& 阅读全文
posted @ 2014-04-02 17:03 kaliu 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 【16课】字符串格式化2元组(tuple)的用法 ,('Mike',87)就是元组print " %s 's score is %d " %('Mike',87)name = 'Lily'score = 90print "%s 's score is %d "%(name,score)【17课】 类型转化int(x)float(x)str(x) 把x转化为字符串bool(x) 以下结果为真int ('123') == 123float( '3.3') == 3 阅读全文
posted @ 2014-04-02 15:12 kaliu 阅读(266) 评论(0) 推荐(0) 编辑