摘要: 简介 文件的读写操作几乎是每门语言都有的基础。python的文件操作过程可以分成以下三步: 下面就按这三步来,简单总结一下。 open()打开一个文件 在对文件进行操作时,我们首先是使用open()函数来打开一个文件,从而获得它的文件操作符(也有称文件句柄),不论是读操作还是写操作,都是使用open 阅读全文
posted @ 2018-06-02 09:15 皇者风范 阅读(229) 评论(0) 推荐(0) 编辑
摘要: {1, 2, (3, 4)}{1, 2, (11, 22, 33), (3, 4)}{1, 2, 4, 5, 6, 'b', 'e', 'g', (11, 22, 33), 'f', 333, 111, 'c', 'a', 'd', (3, 4), 222}{1, 2, 4, 5, 6, 'b', 阅读全文
posted @ 2018-05-30 10:37 皇者风范 阅读(87) 评论(0) 推荐(0) 编辑
摘要: data = { '北京':{ '昌平':{ '沙河':{'old_boy','test'}, '天通苑':{'链家地产','我爱我家'} }, '朝阳':{ '望京':['奔驰','陌陌'], '国贸':['CICC','HP'], '东直门':['Advent','飞信'] }, '海淀': 阅读全文
posted @ 2018-05-25 22:28 皇者风范 阅读(188) 评论(0) 推荐(0) 编辑
摘要: name = "my \tname is {name} and i am {year} old"print(name.capitalize())print(name.count("a"))print(name.center(50,"-"))print(name.encode())print(name 阅读全文
posted @ 2018-05-25 22:24 皇者风范 阅读(106) 评论(0) 推荐(0) 编辑
摘要: product_list = [ ('Iphone',5800), ('Mac Pro',9800), ('Bike',800), ('Watch',10600), ('Coffee',34), ('Alex Python',120)]shopping_list = []while True: sa 阅读全文
posted @ 2018-05-25 15:32 皇者风范 阅读(231) 评论(0) 推荐(0) 编辑
摘要: list1 = ["ZhangSan","LiSi","WangErma","LiuZhong"] list3 =[7,8,9] print(list1[1]) print(list1.count("LiZhong")) list1.append("MaWentao") #del list1[1] 阅读全文
posted @ 2018-05-24 21:11 皇者风范 阅读(80) 评论(0) 推荐(0) 编辑
摘要: #part1: name =input("name:") age =int(input("age:")) print(type(age),str(type(age))) job =input("job:") salary =input("salary:") info = ''' info of %s 阅读全文
posted @ 2018-05-24 20:15 皇者风范 阅读(112) 评论(0) 推荐(0) 编辑
摘要: age_of_Haitao =32 count =0 while count<3: guess_age = int(input("guess age:")) if guess_age == age_of_Haitao: print("Yse,you got it!") break elif gues 阅读全文
posted @ 2018-05-23 21:38 皇者风范 阅读(86) 评论(0) 推荐(0) 编辑