Python学习记录

Python的创始人为
吉多·范罗苏姆
(Guido van Rossum)

    Python英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/),是一种面向对象直译式电脑程序语言。它包含了一组功能完备的标准库,能够轻松完成很多常见的任务。它的语法简单,与其它大多数程序设计语言使用大括号不一样,它使用缩进来定义语句块。

    与SchemeRubyPerlTcl动态语言一样,Python具备垃圾回收功能,能够自动管理内存使用。它经常被当作脚本语言用于处理系统管理任务和网络程序编写,然而它也非常适合完成各种高级任务。Python虚拟机本身几乎可以在所有的操作系统中运行。使用一些诸如py2exe、PyPy、PyInstaller之类的工具可以将Python源代码转换成可以脱离Python解释器运行的程序。

    Python的官方解释器是CPython,该解释器用C语言编写,是一个由社区驱动的自由软件,目前由Python软件基金会管理。

Python支持命令式程序设计面向对象程序设计函数式编程面向侧面的程序设计泛型编程多种编程范式。

使用Python执行Linux命令

2020年05月10日

使用Python执行Linux命令,具体可看这篇文章:Python Execute Unix / Linux Command Examples

python 判断list是否为空

2020年04月27日

判断python list是否为空,有以下几种写法:a = [] if not a: print("List is empty")根据长度判断:a = [] if not len(a): print("List is empty")或则是这么写:a = [] if len(a) == 0: print("List is empty")两个空list对...

TypeError: can only concatenate str (not "list") to str

2020年04月27日

最近在写代码的时候,出现了如下错误:TypeError: can only concatenate str (not "list") to str具体截图如下:出现错误的原因:类型错误,具体代码如下:response = drive_service.files().list( q="mimeType='application/vnd.google-...

google drive Insufficient Permission: Request had insufficient authentication scopes.

2020年04月24日

最近再使用Google Drive新建文件夹的时候,出现了如下错误:googleapiclient.errors.HttpError: HttpError 403 when requesting https://www.googleapis.com/drive/v3/files?fields=id&alt=json returned "Insufficient Permission: Reques...

Python 登录移动查询话费

2020年04月19日

通过python爬虫方式登录10086后台,查询话费。# -*- coding: utf-8 -*- # @Time : 2019-02-22 09:52 # @Author : cxa # @File : beijing_crawler.py # @Software: PyCharm import requests import time import base64 from C...

Python urllib user_agent

2020年04月19日

如果默认不更改Python的urllib user_agent,则user_agent的字符串是:[19/Apr/2020:10:02:44 +0800] "GET / HTTP/1.1" 200 47657 "-" "Python-urllib/3.7"这里摘录的是Nginx的日志文件,可以看到最后一行是默认的Python的urllib user_agent。如果需要自定义urllib的头(he...

Python 时间戳转换

2020年04月19日

1、将timestamp转换成datetime from datetime import datetime timestamp = 1545730073 dt_object = datetime.fromtimestamp(timestamp) print("dt_object =", dt_object) print("type(dt_object) =", type(dt_o...

Python map

2020年04月19日

map() 会根据提供的函数对指定序列做映射。第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。map()语法:map(function, iterable, ...)function -- 函数iterable -- 一个或多个序列下面是一些示例代码:# Python program to demonstrat...