honmaple

风落花语风落天,花落风雨花落田.

  • Poem
  • Cloud
  • TimeLine
  • Archives
  • About me

python笔记

Posted in 2017-01-29 | Category Life.coding | Tags python gist coding | Read 2477

Table of Contents

  • TIME
    • GMT时间格式
    • 获取某个时间的时间戳
    • 得到当天0点时间
    • 时间或时间戳与字符串转换
    • 秒转化为时分秒
    • 获取上个月开始与结束时间
    • 获取上周星期天与星期六
    • 获取上周时间(星期天零点到星期天零点)
  • HTTP
    • 在网址中加入参数
    • urllib2发送json数据 POST请求
    • urllib2发送PUT或DELETE请求
  • Syntax
    • 解析赋值字符串
    • 字典递归更新
    • 字典使用dot
    • 单例模式
  • Pip
    • pip更新所有的packages
  • 判斷是否激活virtualenv
  • Django model得到所有field name
  • python运行超时设置
  • 库
  • 其它
    • 获取文件最后n行数据
    • python列表中去除烦人的"u"

TIME

GMT时间格式

GMT_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'

获取某个时间的时间戳

import datetime
import time

string = "2018-03-31"
date_time = datetime.datetime.strptime(string, '%Y-%m-%d')
time_time = time.mktime …
read more »

lin.jiang

风落花语风落天,花落风雨花落田.
Life 31 Linux 69 Python 43 Security 4 Life.coding 8 Life.recall 5
Tags
life 17 poem 7 linux 65 fedora 2 Life 5 nvidia 1 git 2 C51 3 vim 2 随意写写 7 转载 2 python 49 flask 24 pelican 4
centos 1 shadowsocks 1 sql 5 postgresql 3 sqlite 1 vps 1 ssl 1 nginx 2 pillow 1 验证码 1 python3 2 supervisor 1 web 3 redis 2 ajax 1 jquery 2 markdown 1 wtforms 1 arch 1 jinja2 2 fabric 1 sqlalchemy 7 datetime 1 archlinux 4 md5 1 steam 1 emacs 16 logging 1 wireshark 1 加密解密 1 security 2 virtualbox 3 i3wm 3 restful 1 time 1 串口 1 单片机 1 Linux 2 pip 2 pip3 1 tar 1 honmape 1 config 1 装饰器 1 os 1 thunar 1 job 1 流浪 1 regex 1 netease 2 token 1 json 1 org-mode 1 毕业设计 2 py3status 1 gist 1 coding 3 agetty 1 earth 2 naruto 1 生活随笔 1 himawari8 1 回忆 1 随笔 1 whoosh 1 elisp 4 vue 1 html 1 javescript 1 诗 1 celery 1 ftp 1 tornado 2 ansible 3 lua 2 date 1 travel 2 log 1 docker 1 golang 1 i18n 1 devops 2 elasticsearch 1 javascript 1 css 1
  • © 2015-2019 honmaple
  • ·
  • Friends | Contact | Poem | TimeLine