Python学习记录

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

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

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

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

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

Python not运算

2020年06月13日

下面是一些not运算符:Python 2.7 (r27:82500, Sep 16 2010, 18:02:00) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> True == True ...

TypeError: string indices must be integers

2020年06月04日

最近再处理api返回数据的时候出现了如下错误:TypeError: string indices must be integers具体代码如下:def test_sms_content(self): # 首先向数据库中插入数据 test_insert_database() response_404 = self.client.get('/api...

Python dotenv Command errored out with exit status 1

2020年06月03日

最近再安装dotnev的时候出现了如下错误:ERROR: Command errored out with exit status 1报错截图如下:具体错误原因未查清。解决方案:直接安装python-dotenv,具体命令如下:pip3 install python-dotenv或者执行如下命令:pip install python-dotenv参考资料:1、pip install dotenv ...

使用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...