博客
关于我
python note 06 编码方式
阅读量:804 次
发布时间: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 getattrribute_Python学习——面向对象高级之反射
查看>>
Python进阶语法:字典推导式
查看>>
python gil_Python中GIL的使用详解
查看>>
python glob.glob使用
查看>>
python glob的安装和使用
查看>>
Python google drive API 下载,文件在哪里?
查看>>
Python GPS 模块:读取最新的 GPS 数据
查看>>
python grpc入门
查看>>
python gRPC测试helloworld
查看>>
python list,str的拼接与转换
查看>>
python matplotlib简单使用
查看>>
python os.system
查看>>
Python os.system执行多条语句,os.system的返回值以及与os.popen的区别
查看>>
Python os和sys模块
查看>>
python os文件/目录
查看>>
Python Package 之 Faker(随机姓名、电话)
查看>>
Python Panda TIME 系列重新采样
查看>>
python pandas TimeStamps到夏令时的本地时间字符串
查看>>
Python pandas 数据清洗与数据绘图实战
查看>>
Python Pandas 用顶行替换标题
查看>>