摘要:
1 import getpass 2 import sys 3 f = open('user.db','r') 4 welcome="欢迎来欢乐多购物平台" 5 data = f.read() 6 f.close() 7 user_db_list = [] 8 user_info_list = da 阅读全文
摘要:
#!/usr/bin/env python# -*- coding: utf-8 -*-i = 1while i < 11: if i == 7: i = i + 1 continue print(i) i = i + 1 #!/usr/bin/env python # -*- coding: utf-8 -*- i = 1 while i < 1... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 print('欢迎土豪光临随心所欲旗舰店') 4 user_money = int(input('老板,请输入你拥有的总资产:')) 5 shopping_list = [] 6 shopping_car = {} 7 chose_list = [] 8 out = '谢谢惠顾... 阅读全文
摘要:
#!/usr/bin/env python # -*- coding: utf-8 -*- i = 1 num = 0 while i < 101: num = num + i print(num) #print(i) i = i + 1 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #输出商品列表,用户输入序号,显示用户选中的商品 4 li = ["手机", "电脑", '鼠标垫', '游艇'] 5 6 for i in enumerate(li): 7 print(i) 8 #print(li[1]) 9 #print('老板,看到我们这么丰... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 i = 1 4 #num = 0 5 while i < 101: 6 #num = num + i 7 #print(num) 8 if i % 2 == 1: 9 print(i) 10 i = i + 1 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 import getpass 5 print('欢迎来到不知名星系购物平台') 6 i = 0 7 while i < 3: 8 user_name = input('上帝,请输入您的购物账号:') 9 #user_password = int(getp... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 i = 1 4 while i < 101: 5 #print(i) 6 if i % 2 == 0: 7 print(i) 8 i += 1 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #查找列表中元素,移除每个元素的空格,并查找以 a或A开头 并且以 c 结尾的所有元素 4 #先转换为字符串 5 li = ["alec", " aric", "Alex", "Tony", "rain"] 6 tu = ("alec", " aric", "Alex", "Ton... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #有如下值集合 [11,22,33,44,55,66,77,88,99,90...],将所有大于 66 的值保存至字典的第一个key中,将小于 66 的值保存至第二个key的值中。 4 #即: {'k1': 大于66的所有值, 'k2': 小于66的所有值} 5 agg = [11,... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 i = 1 5 o = 0 6 while i <= 99: 7 if i % 2 ==1: 8 o = o + i 9 elif i % 2 == 0: 10 o = o - i 11 else: 12 ... 阅读全文
摘要:
如果想要类似于执行shell脚本一样执行python脚本,例: ./hello.py ,那么就需要在 hello.py 文件的头部指定解释器,如下:#!/usr/bin/env python# -*- coding: utf-8 -*-ps:执行前需给予 hello.py 执行权限,chmod 75 阅读全文