在python2.x版本中可以直接使用import urllib来进行操作,但是python3.x版本中使用的是import urllib.request来进行操作,下面是简单的例子:

 

python2.x

  

import urllib  
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345'  
text = urllib.urlopen(url).read()  

  

python3.x

 

import urllib.request  
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='  
current = '12345'  
response = urllib.request.urlopen(url+current)  
text = response.read()  
current = text[-5:]  
response = urllib.request.urlopen(url+current)  

  

相关文章:

  • 2021-11-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-11-01
  • 2021-09-27
相关资源
相似解决方案