博客
关于我
python note 06 编码方式
阅读量:800 次
发布时间: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输入输出练习,运算练习,turtle初步练习
查看>>
Python pip工具使用
查看>>
Python pip配置国内源
查看>>
Python Plotly 将轴数格式化为 %
查看>>
Redis 键值过期操作
查看>>
python predictabel_基于R语言PredictABEL包对Logistic回归模型外部验证
查看>>
Python psycopg2 超时
查看>>
Python Pyinstaller Matplotlibrary
查看>>
Python Pypi 修改 国内源(以豆瓣源为例)
查看>>
Python PyQt5 将不再显示此消息复选框添加到 QMessageBox
查看>>
Python PyQt5:如何使用 PyQt5 显示错误消息
查看>>
Python PYSFTP-以字符串/文本形式传递私钥,而不是传递文件路径
查看>>
Python pytest 面试题!
查看>>
Python pytz 时区函数返回一个相差 9 分钟的时区
查看>>
python rabbitmq实现简单/持久/广播/组播/topic/rpc消息异步发送可配置Django
查看>>
Python random和json模块
查看>>
Python random模块seed理解
查看>>
python range()函数
查看>>
Python rdflib可传递查询
查看>>
Redis 配置高可用和搭建集群
查看>>