摘要: 为了避免打开文件后忘记关闭,可以通过管理上下文 with 执行完毕之后 自动关闭且释放资源 阅读全文
posted @ 2017-12-27 18:42 poetL 阅读(529) 评论(0) 推荐(0) 编辑
摘要: eval 功能:将字符串str当成有效的表达式来求值并返回计算结果。 语法: eval(source[, globals[, locals]]) -> value 参数: source:一个Python表达式或函数compile()返回的代码对象 globals:可选。必须是dictionary l 阅读全文
posted @ 2017-12-27 18:32 poetL 阅读(455) 评论(0) 推荐(0) 编辑
摘要: flush()使用 !/usr/bin/python coding: UTF 8 打开文件 fo = open("runoob.txt", "wb") print("文件名为: ", fo.name) 刷新缓冲区 fo.flush() 关闭文件 fo.close() 阅读全文
posted @ 2017-12-27 18:17 poetL 阅读(666) 评论(0) 推荐(0) 编辑
摘要: 1 # -*- coding:utf-8 -*- 2 # __author__ : poetl 3 # date: 2017/12/27 4 5 # 字典特点: 无序, 键唯一 6 7 8 zone ={ 9 '山东' : { 10 '青岛' : ['四方','黄岛','崂山','李沧','城阳'], 11 '济南' : ['... 阅读全文
posted @ 2017-12-27 11:54 poetL 阅读(119) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf-8 -*- # __author__ : poetl # date: 2017/12/26 salary = int(input("Please input your salary:")) balance = salary shop_list = [5800, 1500, 9000, 32, 80] shop_name = ["iphone6s", "bicyl... 阅读全文
posted @ 2017-12-27 00:04 poetL 阅读(343) 评论(0) 推荐(0) 编辑
摘要: for i in range(1, 10): for j in range(1, i + 1): print("%d*%d=%2d" % (i, j, i * j), end=' ') print(" ") for i in range(1, 10): for j in range(1, i + 1 阅读全文
posted @ 2017-12-27 00:03 poetL 阅读(96) 评论(0) 推荐(0) 编辑