zoukankan      html  css  js  c++  java
  • Python网络编程

    我们用到了requests库,由于是第三方的,必须下载

    如果是python 2.x用下面命令

    pip install requests

    python 3.x用下面命令

    easy_install requests

    运行结果:

    Searching for requests
    Reading https://pypi.python.org/simple/requests/
    Best match: requests 2.8.1
    Downloading https://pypi.python.org/packages/source/r/requests/requests-2.8.1.tar.gz#md5=a27ea3d72d7822906ddce5e252d6add9
    Processing requests-2.8.1.tar.gz

    ...

    downloadFile.py

    import requests
    res = requests.get('http://www.gutenberg.org/cache/epub/1112/pg1112.txt')
    res.raise_for_status()
    playFile = open('RomeoAndJuliet.txt', 'wb')
    for chunk in res.iter_content(100000):
        playFile.write(chunk)
    playFile.close()

    运行结果:

    目录下会产生一个文件
    RomeoAndJuliet.txt

  • 相关阅读:
    决策树
    训练/测试
    机器学习 标准差
    pandas01
    提交参数说明
    pandas_series02
    Yarn 模式
    词云图
    软件需求与分析课堂综合测试
    课堂测试10
  • 原文地址:https://www.cnblogs.com/davidgu/p/4973690.html
Copyright © 2011-2022 走看看