目的
为了学学爬虫,爬爬自己学校的网站,看看通知,学一下python
第二天
模块
import os #os模块为例
三元运算
a=1
b=2
c=3
a=b if a>b else c
转码
encode和decode
word="世界"
print("word.encode")
print("word.encode.decode")
列表
list=[1,2,3]
总结
简单的python差不多就是这些了,接下来准备看高级的,加油!
附
结合第一天的内容合成的 程序
# Author:Kevin Yan
salary=input("what is your salary:")
shop=[[1,"cat",400],[2,"dog",522],[3,"monkey",2000],[4,"tiger",4000]]
goods=[]
if salary.isdigit():
saving=int(salary)
while saving>0:
print(shop)
buygood=int(input("which is your choice:"))
if buygood<len(shop) and buygood>0:
saving-=shop[buygood-1][2]
if saving > 0:
goods.append(shop[buygood][1])
print("success,you have brought ",goods)
goingon=input("do you want to contiune:")
if goingon=="no":
print("see you again")
break
else:
print("sorry, you do not have enough money")
else:
print("sorry,goods %d disappear"%buygood)
print("welcome to next coming")~