标签:imp pat load port python3 字典 访问 path --
import sys
name=sys.argv[1]
password=sys.argv[2]
if name==‘jly‘ and password==‘123‘:
print(‘程序继续执行‘)
else:
sys.exit()
--------------------------------------------------------------------------------------
控制台执行结果
G:\学习\Python项目\first>python3 G:\学习\Python项目\first\August\day21\t21.py jly 123
程序继续执行
dic={‘name‘:‘alex‘,‘age‘:23}
dic_str=json.dumps(dic)
dic_dic=json.loads(dic_str)
print(dic_str,type(dic_str))
print(dic_dic,type(dic_dic))
--------------------------------------------------------------------------------------
{"name": "alex", "age": 23} <class ‘str‘>
{‘name‘: ‘alex‘, ‘age‘: 23} <class ‘dict‘>
f=open(‘json‘,‘w‘)
dic={‘name‘:‘alex‘,‘age‘:23}
json.dump(dic,f)
f.close()
f=open(‘json‘)
dic=json.load(f)
f.close()
f=shelve.open(‘shelve_file‘)
f[‘k2‘]={‘int‘:10, ‘float‘:9.5, ‘string‘:‘Sample data‘}
f.close()
f=shelve.open(‘shelve_file‘)
ext=f[‘k2‘]
f.close()
print(ext)
标签:imp pat load port python3 字典 访问 path --
原文地址:http://www.cnblogs.com/lianxuebin/p/7400063.html