博客
关于我
python note 06 编码方式
阅读量:798 次
发布时间:2023-03-06

本文共 811 字,大约阅读时间需要 2 分钟。

li = [11,22,33,44,55,66,77,88,90,99]dic = {}l_high = []  # 大于66的所有值列表l_low = []   # 小于66的所有值列表 for i in li:if i == 66:continueif i > 66:l_high.append(i)else:l_low.append(i) dic['k1'] = l_highdic['k2'] = l_low print(dic)  # 输出{'k2': [11, 22, 33, 44, 55], 'k1': [77, 88, 90, 99]}

flag = Truewhile flag:    li = ["手机", "电脑", "鼠标垫", "游艇"]    for i in li:        print(f"{li.index(i)+1}\t{li[i]}")    choice = input('请输入选择的商品序号/输入Q或者q退出程序:')    if choice.isdigit():        choice = int(choice)        if 1 <= choice <= len(li):            print(li[choice-1])        else:            print('请输入有效数字')    elif choice.upper() == 'Q':        flag = False    else:        print('请输入数字')
s = 'alex's1 = b'alex'print(s, type(s))print(s1, type(s1)) s2 = '中国's22 = s2.encode('utf-8')print(s22)s22 = s2.encode('gbk')print(s22)

转载地址:http://moafk.baihongyu.com/

你可能感兴趣的文章
Python 3.4 多处理递归 Pool.map()
查看>>
Python 3.4:未知格式代码“x“
查看>>
Python 3.5、ldap3 和 modify_password()
查看>>
python 3.6.8 升级至3.9版本升级
查看>>
Python 3.9 到 Python 3.12 的发展历程与区别
查看>>
python 32位和64位的区别在哪
查看>>
Python 3:何时使用 dict,何时使用元组列表?
查看>>
Python 3d 绘图 - 轴居中
查看>>
python ==》 字典
查看>>
python anaconda 安装使用
查看>>
python and或or 当参数传递的时候的用法
查看>>
Python append() 与列表上的 + 运算符,为什么这些会给出不同的结果?
查看>>
Python APP自动化测试工具adb与Monkey使用详解
查看>>
Python APP自动化测试框架Appium详解
查看>>
Python APP自动化测试框架开发实战
查看>>
python argparse模块
查看>>
Python asyncio库的学习和使用
查看>>
Python AttributeError:“dict“对象没有属性“append“
查看>>
Python base64和hashlib模块
查看>>
python basic programs
查看>>