![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python 学习之路
幽灵@爵士
这个作者很懒,什么都没留下…
展开
-
python中的encode()和decode()函数
字符串转二进制用decode二进制转字符串用encode举例:msg="hello 世界你好"print(msg)print(msg.encode("utf-8"))print(msg.encode("utf-8").decode("utf-8"))原创 2020-12-20 16:30:53 · 275 阅读 · 0 评论 -
python模块学习
1.sys模块1.sys.path环境变量2.sys.argv当前文件的路径2.os模块1.os.system结果直接输出到屏幕上,并不会储存到内存里,只执行命令,不保存结果import oscmd_res=os.system("dir")print("--->",cmd_res)2.os.popen实例1import oscmd_res=os.popen("dir")print("--->",cmd_res)实例2import oscmd_res=os.p原创 2020-12-19 17:05:10 · 138 阅读 · 3 评论 -
while循环与for循环的区别,猜大小
while循环,猜大小password = 123count=0while count<3: in_password=int(input("please input your password:"))#in_username=input("please input your username:") if in_password == password: print("welcome to our home") break elif in原创 2020-12-19 15:16:53 · 209 阅读 · 1 评论 -
Day 2 知识学习
格式化输出1. %的用法参照链接: linka. 整数格式化%o——八进制 octonary%d——十进制 decimal%x——十六进制 hexadecimalprint("%o" % 20)print("%d" % 20)print("%x" % 20)显示结果:242014b.浮点型格式化%f 默认保留6位有效数字%.3f 保留3位小数数字%e 以指数形式保留6位有效数字%.3e 保留3位小数数字,以科学计数法方式%g 以小数或指数形式保留6位有效数字%.3原创 2020-12-11 15:56:09 · 128 阅读 · 0 评论