![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python基础
BOBO_GO
每天进步多一点
展开
-
python新增语法f-string
x=12 y=15 print(f'{x+y}') #python3.6 #27 print(f'{x+y=}') #python3.8 #12+15=27 dict={'a':100,'b':200} print(f'{dict["a"]}')原创 2020-07-29 08:40:44 · 151 阅读 · 0 评论 -
字符串
内建函数 方法 描述 string.capitalize() 把字符串的第一个字符大写 string.center(width) 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串 string.count(str, beg=0, end=len(string)) 返回 str 在 string 里面出现的次数,如果 beg 或者 end 指定则返回指定范围内 str 出...原创 2018-12-12 17:14:12 · 59 阅读 · 0 评论 -
字典
内置函数 Python字典包含了以下内置函数: 序号 函数及描述 1 cmp(dict1, dict2) 比较两个字典元素。 2 len(dict) 计算字典元素个数,即键的总数。 3 str(dict) 输出字典可打印的字符串表示。 4 type(variable) 返回输入的变量类型,如果变量是字典就返回字典类型。 Python字典包含了以下内置方法: 内置方法 序号 函数及描述 1 ...原创 2018-12-12 17:07:13 · 80 阅读 · 0 评论 -
列表&元组
列表的函数 1 cmp(list1, list2) 比较两个列表的元素 2 len(list) 列表元素个数 3 max(list) 返回列表元素最大值 4 min(list) 返回列表元素最小值 5 list(seq) 将元组转换为列表 列表的方法 1 list.append(obj) 在列表末尾添加新的对象 2 list.count(obj) 统计某个元素在列表中出现的次数 3 list...原创 2018-12-12 16:54:39 · 226 阅读 · 0 评论 -
逻辑运算符
'''x or y x True,则返回x''' print(1 or 2) # 1 print(3 or 2) # 3 print(0 or 2) # 2 print(0 or 100) # 100 print(2 or 100 or 3 or 4) # 2 print(0 or 4 and 3 or 2) '''x and y x True,则返回y''' print(1 an...原创 2018-12-12 16:41:23 · 88 阅读 · 0 评论 -
编码
01010100 新 11010000 开 11010100 一 01100000 家 11000000 看 11000000 看 01010100011101110101011110110 A B C 01000001 01000010 01000011 电报,电脑的传输,存储都是01010101 最早的'密码本' ascii 涵盖了英文字母大小写,特殊字符,数字。 01010101 asc...原创 2018-12-12 16:37:55 · 120 阅读 · 0 评论 -
Python2和Python3的差异
基本语法差异 核心类差异 Python3对Unicode字符的原生支持 Python2中使用 ASCII 码作为默认编码方式导致string有两种类型str和unicode,Python3只支持unicode的string。python2和python3字节和字符对应关系为: Python3采用的是绝对路径的方式进行import。 Python2中相对路径的import会导致标准库导入变得困难(...转载 2018-12-28 08:58:44 · 91 阅读 · 0 评论