code 1 can run in python2.6<br>#coding:utf-8<br>import urllib <br>import lxml.html<br>down='http://frux.wikispaces.com/'<br>root=urllib.urlopen(down).read()<br>root=lxml.html.fromstring(root)<br>file=root.xpath('//a')<br>for i  in  file:<br>    str1=i.text_content()<br>    if str1.find('pdf')  >-1 :<br>        str2='http://frux.wikispaces.com/file/view/'+str1<br>        myfile=urllib.urlopen(str2).read()<br>        book=open('/tmp/'+str1,'w')<br>        book.write(myfile)<br>        book.close()<br><br> i usr command :  2to3-3.2  ~/xml.py  -w  to get  code2<br><br>#coding:utf-8<br>import urllib.request, urllib.parse, urllib.error <br>import lxml.html<br>down='http://frux.wikispaces.com/'<br>root=urllib.request.urlopen(down).read()<br>root=lxml.html.fromstring(root)<br>file=root.xpath('//a')<br>for i  in  file:<br>    str1=i.text_content()<br>    if str1.find('pdf')  >-1 :<br>        str2='http://frux.wikispaces.com/file/view/'+str1<br>        myfile=urllib.request.urlopen(str2).read()<br>        book=open('c:\'+str1,'w')  #  i  change it  <br>        book.write(myfile)<br>        book.close()<br><br>when i run it  in  python32,the output is  :<br>book=open('c:\'+str1,'w')   <br>invalid  syntax,what is wrong?<br>