博客
关于我
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网络爬虫实例教程试读_Python网络爬虫实战教程(全套完整版) - 学途无忧网 - 做技术的王者 - Powered By EduSoho...
查看>>
Python 使用哈希函数用于加密
查看>>
Python 依赖管理的革新——Poetry 深度解析
查看>>
python 保留精度及增加去除数字的千位分隔符(金额化数字)
查看>>
python 倒计时 9,8,7,。。。。。。0
查看>>
Python 入门开发学习笔记之数据的增删改查
查看>>
Python 入门教程(2)搭建环境 2.4、VSCode配置Node.js运行环境
查看>>
Python 八大排序算法合集
查看>>
python 关于epoll的学习
查看>>
Python 内存管理
查看>>
Python 内嵌函数:它们有什么用处?
查看>>
Python 内置 sum 函数 vs. for 循环性能
查看>>
python 内置slice的用法
查看>>
Python 内置时间模块
查看>>
python 内部如何实现命名元组?
查看>>
Python 写Android App性能:入门到高级
查看>>
python 写入json数据到数据库
查看>>
Python 出现 TypeError: ‘encoding‘ is an invalid keyword argument for this function 解决方法
查看>>
python 出现 TypeError: ‘list‘ object is not callable 的解决方法
查看>>
python 函数1
查看>>