摘要: 1,def 定义函数def test1(): print ('in the test1')def test2(): print ('in the test2') return 2def test3(): print ('in the test3') return 1,'hello',[1,2,3],{'name':'Tom'}x = test1()y = test2(... 阅读全文
posted @ 2017-06-03 10:56 包八力 阅读(94) 评论(0) 推荐(0)
摘要: 1,文件编码 python默认编码,python2默认为ascii,python3默认为utf-8所以说,python3默认支持中文。 2,文件操作通过指针的移动在读取文件,文件打开,指针指向文件开头,文件读完,指针指向文件末尾,指针不会自动回到文件开头,所以说,文件只能读一遍,如果想想再一次从头读 阅读全文
posted @ 2017-06-01 23:41 包八力 阅读(276) 评论(0) 推荐(0)
摘要: 1,购物车小程序 需求: (1),启动程序后,打印全部商品列表,用户输入工资 (2),许用户根据商品编号购买商品 (3),用户购买商品,余额不足就退出程序,并打印信息 (4),可随时退出,退出时,打印已购买商品和余额 2,流程图 3,代码 4,测试 阅读全文
posted @ 2017-05-31 22:42 包八力 阅读(133) 评论(0) 推荐(0)
摘要: #!/usr/bin/python3#字典---增删改查#穿件一个字典info>>> info = {... 'student01':'TenLan Wu',... 'student02':'LongZe Luola',... 'student03':'XiaoZe Maliya'... ... } #字典查询 >>> inf... 阅读全文
posted @ 2017-05-31 17:38 包八力 阅读(162) 评论(0) 推荐(0)
摘要: #!/usr/bin/python3#元组:元组是一个只读列表,也是村一组数,一旦创建,便不能在修改>>> tuple1 = ('cisco','huawei','vmware') >>> tuple1.count('cisco') #查看元素在元组中出现的次数1>>> tuple1.index('cisco') #查看元素在元组中的位置0>>> #string字符,字符串的操作不会改... 阅读全文
posted @ 2017-05-31 15:43 包八力 阅读(588) 评论(0) 推荐(0)
摘要: #!/usr/bin/python3 #使用哪个python解释器运行该脚本#python3默认编码为unicode,支持中文name = '侯亮平'print (name)#用户输入函数input()import getpassUsername = input('Username:')Passwd = input('Passwd:')Passwd_get = getpass.get... 阅读全文
posted @ 2017-05-30 23:58 包八力 阅读(299) 评论(0) 推荐(0)
摘要: #!/usr/bin/python3 #三元运算 a,b,c = 1,2,3d = a if a>b else cprint (d)#列表:增删改查>>> name =[1,4,5,3,2,6,8,9,7,10] #定义一个列表name#查>>> len(name) #列表长度10>>> name #查询整个列表[1, 4, 5, 3, 2, ... 阅读全文
posted @ 2017-05-30 20:06 包八力 阅读(211) 评论(0) 推荐(0)