Python3新特性 类型注解 以及 点点点 ... Python3 的新特性 Python 是一种动态语言,变量以及函数的参数是 不区分类型 的 在 函数中使用类型注解 相当于 给 形参的 类型 设置了一个备注 # 使用类型注解 a b 参数需要 int 类型的 变量 def func(a: int = ..., b: int = ...): return a + b 使用 PyCharm 编写python代码时 函数调用会有默认参数的 提示 如果传递的 参数不是 指定的类型 正常使用也不会报…
f-string 1.介绍 f-string(formatted string literals):格式化字符串常量,是Python3.6新引入的一种字符串格式化方法,使格式化字符串的操作更加简便. 2.语法 f'xxx' 或 F'xxx' 且以大括号 {} 表明被替换的字段,{}里面可以是字符串或者表达式 3.实例 简单替换字符串:{'字符串'} name = 'zwq' ret = f'我的名字是:{name}' print(ret) #我的名字是:zwq 计算表达式:{表达式} ret =…
1.系统环境,必要知识 #cat /etc/redhat-release CentOS Linux release (Core) #uname -r -.el7.x86_64 暂时关闭防护墙,关闭selinux: #systemctl stop firewalld.service #setenforce #getenforce Permissive 准备知识: django:一个基于python的开源web框架. uWSGI:一个基于自有的uwsgi协议,wsgi协议和http服务协议的web网…
Python3安装turtle提示错误:Command "python setup.py egg_info" failed with error code 1 Python3.5安装turtle: pip3 install turtle 提示错误: Collecting turtle Using cached https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c…
Anaconda(3-5.0.1,Python3.6)下载链接:https://pan.baidu.com/s/1bqFwLMB 密码:37ih Pycharm(community-2017.3.3)下载链接:https://pan.baidu.com/s/1bqeOYy7 密码:91ds OpenCV(python‑3.4.0‑cp36‑cp36m)下载链接:https://pan.baidu.com/s/1bqSnZjh 密码:9kkr windows下如何快速优雅的使用python的科学计…
原文链接:https://www.cnblogs.com/abclife/p/7445222.html python 3中最重要的新特性可能就是将文本(text)和二进制数据做了更清晰的区分.文本总是用unicode进行编码,以str类型表示:而二进制数据以bytes类型表示. 在python3中,不能以任何隐式方式将str和bytes类型二者混合使用.不可以将str和bytes类型进行拼接,不能在str中搜索bytes数据(反之亦然),也不能将str作为参数传入需要bytes类型参数的函数(反…
(转载)File(File f, String child) 根据f 抽象路径名和 child 路径名字符串创建一个新 File 实例. f抽象路径名用于表示目录,child 路径名字符串用于表示目录或文件 f - 父抽象路径名 child - 子路径名字符串 File(String parent, String child) 根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例. parent 路径名字符串用于表示目录,child 路径名字符串用于表示目录或文…
python3.4学习笔记(二十六) Python 输出json到文件,让json.dumps输出中文 实例代码 python的json.dumps方法默认会输出成这种格式"\u535a\u5ba2\u56ed",.要输出中文需要指定ensure_ascii参数为False,如下代码片段:json.dumps({'text':"中文"},ensure_ascii=False,indent=2) import json #导入json格式 if __name__ ==…
python3.4学习笔记(二十五) Python 调用mysql redis实例代码 #coding: utf-8 __author__ = 'zdz8207' #python2.7 import redis, json, re, time import MySQLdb import MySQLdb.cursors HOST = "127.0.0.1" USER = "db username" PASSWD = "your password"…
python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法window安装redis,下载Redis的压缩包https://github.com/dmajkic/redis/downloads 如redis-2.4.5-win32-win64.zip下载完后将其解压放在自己要放的目录下如果你是32位的话就进32bit的文件夹,64位就进64bit文件夹 文件夹进去后会看到几个文件:redis-benchmark.exe: 性能…