2018年5月2日
摘要: user_db : 阅读全文
posted @ 2018-05-02 09:51 PAYNE1Z 阅读(994) 评论(0) 推荐(0)
  2018年4月28日
摘要: # data = open('nothing_on_you.txt', encoding='utf-8').read() f = open('nothing_on_you.txt', 'r', encoding='utf-8') # 只读 data = f.read() data2 = f.read() print(data, '-------------', data2) # r 模式读文件... 阅读全文
posted @ 2018-04-28 11:06 PAYNE1Z 阅读(199) 评论(0) 推荐(0)
摘要: count = 0 while True: print(count) count = count + 1 # count += 1 if count == 100: break while count 10: continue print(count) count += 1 for i in range(10): print... 阅读全文
posted @ 2018-04-28 11:05 PAYNE1Z 阅读(80) 评论(0) 推荐(0)
摘要: a, b, c = 1, 3, 5 print(a, b, c) d = a if a > b else c # 三元操作符:如果 a>b 则 d=a 否则 d=c print(d) d = a if a < b else c # 三元操作符:如果 a<b 则 d=a 否则 d=c print(d) # 用三元操作符找出较小的那个 x, y = 3987, 24361 small = (... 阅读全文
posted @ 2018-04-28 11:04 PAYNE1Z 阅读(113) 评论(0) 推荐(0)
摘要: #!/usr/bin/env python # -*- coding:utf-8 -*- # Author: Payne Zheng list_1 = [1, 2, 4, 5, 7, 9] list_1 = set(list_1) list_2 = set([2, 3, 4, 6, 8, 0]) # 创建一个数值集合 # 交集 (两个集合都有的) print(list_1.intersec... 阅读全文
posted @ 2018-04-28 11:03 PAYNE1Z 阅读(90) 评论(0) 推荐(0)
摘要: # 字典是一种 key-value 数据类型 # 字典是无序的(没有下标),key 必须是唯一的,所以天生去重 info = { 'n01': "jason", 'n02': "leo", 'n03': "holly", } info2 = { 'n01': 'payne', 'n10': 'male', 'n20': 'olive' } p... 阅读全文
posted @ 2018-04-28 11:02 PAYNE1Z 阅读(105) 评论(0) 推荐(0)
摘要: name = "my name is {name}, {year} old" print(name.capitalize()) # 首字母大写 print(name.count('n')) # 字符统计 print(name.center(50, '+')) # 如果字符串不够50个,那么就用+号来凑足50个并将字符串居中在+号中间 print(name.ljust(50, '*')) # 如... 阅读全文
posted @ 2018-04-28 11:00 PAYNE1Z 阅读(108) 评论(0) 推荐(0)
摘要: import sys # python3 中字符编码默认为 utf-8 s = '你好' print(s) # utf-8 转为 gbk (s 默认为 unicode 所以可以直接 encode 成 gbk) s_to_gbk = s.encode('gbk') print('gbk', s_to_gbk) print('default', s.encode()) print('... 阅读全文
posted @ 2018-04-28 10:59 PAYNE1Z 阅读(129) 评论(0) 推荐(0)
摘要: rep_word = 'The piece is gone, left the puzzle undone' # \ 换行,跟shell一样 with open('nothing', 'r', encoding='utf-8') as f, \ open('nothing1', 'w', encoding='utf-8') as f_new: for line in f... 阅读全文
posted @ 2018-04-28 10:50 PAYNE1Z 阅读(140) 评论(0) 推荐(0)
  2018年4月18日
摘要: #!/usr/bin/env python3 # _*_ coding:utf-8 _*_ # # Author: Payne Zheng # Date: 2018-04-12 16:41:15 # Location: DongGuang # Desc: shopping car # """ 1、启动程序后,输入用户名密码后,让用户输入工资,然后打印商品列表 2、允许用户... 阅读全文
posted @ 2018-04-18 22:40 PAYNE1Z 阅读(186) 评论(0) 推荐(0)