import urllib.request import sys import json for i in range(1300000, 1300001): url ='http://api.showji.com/Locating/default.aspx?m=%s&output=json' % i response = urllib.request.urlopen(url) try: for line in response.readlines(): file = open("1.txt", 'a') line = line.decode() print(type(line)) line += '\n' print(line) file.write(line) finally: file.close() #sys.exit() ...
by seacoastboy - Python - 2009-08-07 13:09:16 阅读(1354) 回复(2)
def _decodeHtmlEntity(s): '''十进制unicode转换''' import re result = s entityRe = '( (\\d{5}); )' entities = re.findall(entityRe, s) for entity in entities : result = result.replace...
import urllib.response
报错
Traceback (most recent call last):
File "E:/py/urllib.py", line 2, in
python3.1的change log里有这样一句 - Issue #4753: By enabling a configure option named '--with-computed-gotos' on compilers that support it (notably: gcc, SunPro, icc), the bytecode evaluation loop is compiled with a new dispatch mechanism which gives speedups of up to 20%, depending on the system, on various benchmarks. 看来python会更多的关注性能了。 大家应该多关注python3.x的发展,虽说库现...
http://blog.chinaunix.net/u1/42287/showart_371568.html http://www.python.org/ftp/python/3.0/python-3.0a1.tgz http://docs.python.org/dev/3.0/
http://www.python.org/ftp/python/3.0/python-3.0a1.tgz http://docs.python.org/dev/3.0/ 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/42287/showart_371568.html
当要使函数接收元组或字典形式的参数的时候,有一种特殊的方法,它分别使用*和**前缀。这种方法在函数需要获取可变数量的参数的时候特别有用。例子: 其中:使用字典的items方法,来使用字典中的每个键/值对。 [color="#008080"]##encoding:utf-8 [color="#008080"]# parameter_tuple.py [color="#0000ff"]def [color="#000000"]avarage([color="#00c600"]*[color="#808000"]tuple[color="#00...