# sys模块
# import sys
# sys.path
# sys.argv
# sys.exit() # 脚本退出
# print('[%s]'%('#'*1))
# print('[%s]'%('#'*2))
# print('[%s]'%('#'*3))
# print('[%s]'%('#'*4))
# print('[%s]'%('#'*5))
# print('[%-50s]'%('#'*1))
# print('[%-50s]'%('#'*2))
# print('[%-50s]'%('#'*3))
# print('[%-50s]'%('#'*4))
# print('[%-50s]'%('#'*5))
'''
[#]
[##]
[###]
[####]
[#####]
[# ]
[## ]
[### ]
[#### ]
[##### ]
'''
# print('%d%%'%30) # 30%
# print('[%%-%ds]'%50)
# print(('[%%-%ds]'%50)%('#'*1))
# print(('[%%-%ds]'%50)%('#'*2))
# print(('[%%-%ds]'%50)%('#'*3))
# print(('[%%-%ds]'%50)%('#'*4))
# print(('[%%-%ds]'%50)%('#'*5))
'''
[%-50s]
[# ]
[## ]
[### ]
[#### ]
[##### ]
'''
# def progress(percent,width=50):
# show_str=('[%%-%ds]'%width)%('#'*int(width*percent))
# print('\r%s'%show_str,end='') # progress(0.1)
# progress(0.2)
# progress(0.3)
# progress(0.4)
# progress(0.5)
'''
[##### ]
[########## ]
[############### ]
[#################### ]
[######################### ]
'''
# def progress(percent,width=50):
# show_str=('[%%-%ds]'%width)%('#'*int(width*percent))
# print('\r%s'%show_str,end='')
# progress(0.1)
# progress(0.2)
# progress(0.3)
# progress(0.4)
# progress(0.5)
'''
[######################### ]
'''
# def progress(percent,width=50):
# show_str=('[%%-%ds]'%width)%('#'*int(width*percent))
# print('\r%s %d%%'%(show_str,int(100*percent)),end='')
# progress(0.1)
# progress(0.2)
# progress(0.3)
# progress(0.4)
# progress(0.5)
'''
[######################### ] 50%
'''
# import time
# def progress(percent,width=50):
# show_str=('[%%-%ds]'%width)%('#'*int(width*percent))
# print('\r%s %d%%'%(show_str,int(100*percent)),end='')
# recv_size=0
# total_size=198749
# while recv_size < total_size:
# time.sleep(0.1)
# recv_size+=1034
# progress(recv_size/total_size)
'''
[##################################################] 100%
'''
# import time
# def progress(percent,width=50):
# show_str=('[%%-%ds]'%width)%('#'*int(width*percent))
# print('\r%s %d%%'%(show_str,int(100*percent)),end='')
# recv_size=0
# total_size=10241
# while recv_size < total_size:
# time.sleep(0.1)
# recv_size+=1024
# progress(recv_size/total_size)
'''
[######################################################] 109%
'''
# import time
# def progress(percent,width=50):
# if percent >= 1:
# percent=1
# show_str=('[%%-%ds]'%width)%('#'*int(width*percent))
# print('\r%s %d%%'%(show_str,int(100*percent)),end='')
# recv_size=0
# total_size=10241
# while recv_size < total_size:
# time.sleep(0.1)
# recv_size+=1024
# progress(recv_size/total_size)
'''
[##################################################] 100%
'''
# 序列化可以将内存中的数据结构保存下来,字典 ,列表,元组,字符串...
# dic={'a':1}
# with open('db.txt','w',encoding='utf-8')as f:
# f.write(str(dic))
# with open('db.txt','r',encoding='utf-8')as f:
# dic=eval(f.read())
# print(dic['a'])
'''
1
'''
'''
内存中结构化的数据<->格式json<->字符串<->保存到文件中或基于网络传输
'''
# eval("[null,false,1]")
# [null,false,1]
# import json
# dic={'a':1}
# res=json.dumps(dic)
# print(res,type(res))
'''
{"a": 1} <class 'str'>
'''
# import json
# dic={'a':1}
# res=str(dic)
# print(res,type(res))
'''
{'a': 1} <class 'str'>
'''
# import json
# x=None
# print(json.dumps(x))
'''
null
'''
# import json
# user={'name':'egon','age':18,'nb':True}
# # with open('user.json','w',encoding='utf-8')as f:
# # f.write(json.dumps(user))
# json.dump(user,open('user_new.json','w',encoding='utf-8'))
# import json,time
# user={'name':'egon','age':18,'nb':True}
# with open('user.json','w',encoding='utf-8')as f:
# f.write(json.dumps(user))
# students=['egon','wer','axjl']
# json.dump(students,open('students.json','w',encoding='utf-8'))
# time.sleep(500)
'''
别的文件拿过来的
import json
with open('user.json','r',encoding='utf-8')as f:
user=json.loads(f.read())
print(user['name']) # egon user=json.load(open('user.json','r',encoding='utf-8'))
print(user['age']) # 18
print(user['nb']) # True
'''
# json_str='{"count":1}'
# print(json.loads(json_str))
# print(json.loads(json_str)['count'])
'''
{'count': 1}
1
'''
# pickle
# 可以识别python的所有数据类型
# 但是不能跨平台
# import pickle,json
# s={1,2,3,4}
# # print(json.dumps(s))
# print(pickle.dumps(s))
'''
b'\x80\x03cbuiltins\nset\nq\x00]q\x01(K\x01K\x02K\x03K\x04e\x85q\x02Rq\x03.'
'''
# with open('s.pkl','wb')as f:
# f.write(pickle.dumps(s)) # pickle.dump(s, open('s.pkl','wb'))
'''
import pickle with open('s.pkl','rb')as f:
s=pickle.loads(f.read())
print(s,type(s)) {1, 2, 3, 4} <class 'set'>
'''
'''
import pickle
s=pickle.load(open('s.pkl','rb'))
print(s,type(s))
{1, 2, 3, 4} <class 'set'>
'''

最新文章

  1. iOS创建安全的单例
  2. Weblogic日志机制详解
  3. input 的blur事件之后button的onclick事件不执行解决方案
  4. 【译】Java中的对象序列化
  5. Vcenter server 5.5克隆模板(创建ISO镜像)
  6. fpm打包redis3.0.7
  7. 批量导出表数据到CSV文件
  8. [Java Concurrent] 多线程合作 wait / notifyAll 的简单案例
  9. python中,str和repr的区别
  10. JQuery的Select操作集合
  11. Bootstrap的文档大概介绍
  12. 【Spark2.0源码学习】-4.Master启动
  13. Spring mybatis源码篇章-NodeHandler实现类具体解析保存Dynamic sql节点信息
  14. android 删除相册图片并同步到图库
  15. js 对日期处理
  16. 【问题解决方案】之 hadoop 用jps命令后缺少namenode的问题
  17. Merge Into 语句代替Insert/Update在Oracle中的应用实战
  18. c# 通过.net自带的chart控件绘制饼图pie chart
  19. protobuffer
  20. 测试用Word2007发布博客文章

热门文章

  1. postgresql批量删除表
  2. Visual Studio使用技巧 +谷歌浏览器使用技巧总结
  3. After laptop installed fedora23
  4. PANIC: Missing emulator engine program for ‘x86’ CPU.
  5. VMware 虚拟化编程(1) — VMDK/VDDK/VixDiskLib/VADP 概念简析
  6. Visual Studio格式化所有文档
  7. 【Unity Shader】---UnityShader 提供的CG/HLSL语义
  8. Common Linux Commands 日常工作常用Linux命令
  9. IDEA-关闭自动保存&amp;标志修改文件为星号(一)
  10. 如何理解ajax的同步和异步?