zoukankan      html  css  js  c++  java
  • python入门常用方法(转json,模拟浏览器请求头,写入文件)

    转json
    import json
    json = json.loads(html)

      

    模拟浏览器请求头

    import urllib.request


    req = urllib.request.Request(url, data) req.add_header('User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36')

      

    写入数据

    file_object = open('content.txt', 'w')
    file_object.write(content)
    file_object.writelines(list_of_text_strings)  #写入多行
    file_object.close()
    

      

    文件夹

    import os


    folder = 'girlimage'
    os.mkdir(folder) #创建目录
    os.chdir(folder) #改变当前目录,到指定目录中。
    

      

    python 字符串长度

    python100例:http://www.iplaypy.com/python-100/
    

      

    python100例:https://www.cnblogs.com/devin-guwz/p/5738676.html

    https://www.cnblogs.com/huangcong/archive/2011/08/29/2158268.html

  • 相关阅读:
    C语言中标识符的作用域、命名空间、链接属性、生命周期、存储类型
    循环练习
    ArrayList集合

    方法
    表单标签
    HTML基础
    二维数组
    一维数组
    switch选择结构
  • 原文地址:https://www.cnblogs.com/cxscode/p/8081222.html
Copyright © 2011-2022 走看看