#coding:utf-8<br>import urllib<br>exchange=['NASDAQ','NYSE','AMEX']<br>for down in exchange:<br>    myfile=open('./'+down,'w')<br>    url='http://www.nasdaq.com/screening/companies- \  by-industry.aspx?exchange='+down+'&render=download'<br>    file=urllib.urlopen(url).read()<br>    myfile.write(file)<br>    print ('ok',down)<br>    myfile.close()<br><br>it can run in ubuntu+python2.6 ,when it run in window xp+python32,the output is  <br>Traceback (most recent call last):<br>  File "C:\Python32\getcode.py", line 8, in <module><br>    file=urllib.urlopen(url).read()<br>AttributeError: 'module' object has no attribute 'urlopen'<br><br>i change it into:<br>#coding:utf-8<br>import urllib.request<br>exchange=['NASDAQ','NYSE','AMEX']<br>for down in exchange:<br>    myfile=open('./'+down,'w')<br>    url='http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange='+down+'&render=download'<br>    file=urllib.request.urlopen(url).read()<br>    myfile.write(file)<br>    print ('ok',down)<br>    myfile.close()<br><br>the output is :<br>Traceback (most recent call last):<br>  File "C:\Python32\getcode.py", line 9, in <module><br>    myfile.write(file)<br>TypeError: must be str, not bytes<br><br>how to make it run in xp+python32?<br><br><br><br><br><br>