会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
abel2020
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
4
5
6
7
8
9
10
11
12
···
14
下一页
2020年6月13日
1 vim 基本操作
摘要: 1 移动命令 行数定位: gg 移动到文件首部 G 移动到文件末尾 15gg 移动到15行 屏幕移动: ctrl b 向前翻页 ctrl f 向后翻页 H 文件头部 M 文件中间 L 文件底部 行移动: 0 移动到行首 w 向后移动一个单词 b 向前移动一个单词 段落移动: { 上 } 下 % 寻找
阅读全文
posted @ 2020-06-13 13:14 abel2020
阅读(163)
评论(0)
推荐(0)
2020年6月12日
27 文件及目录操作
摘要:
阅读全文
posted @ 2020-06-12 23:50 abel2020
阅读(128)
评论(0)
推荐(0)
31 文件复制
摘要: # #打开文件 file1 = open("test2.py") #默认只读 file2=open("test2.py.copy","w") # w 覆盖写, a 追加,没有文件都会创建 #读取文件 text = file1.read() #写入文件 file2.write(text) #关闭文件
阅读全文
posted @ 2020-06-12 23:43 abel2020
阅读(153)
评论(0)
推荐(0)
30 文件操作
摘要: #1 打开文件,open 函数 file1 = open("test2.py") #2读取文件,read text = file1.read() #返回字符串类型 print(text) #3 关闭文件 file1.close() # file1 = open("test2.py") text =
阅读全文
posted @ 2020-06-12 22:59 abel2020
阅读(125)
评论(0)
推荐(0)
29 导入包练习
摘要: 1 新建 python Package : mess 文件夹,自动生成空的 __init__.py ,创建send_mess ,receive_mess 两个测试文件, __init__.py 如下: from . import receive_mess from . import send_mes
阅读全文
posted @ 2020-06-12 18:54 abel2020
阅读(103)
评论(0)
推荐(0)
28 代码格式
摘要: #导入模块 #定义全局变量 #定义类 #定义函数 def main(): pass # ... print("测试本py代码") if __name__ == '__main__': # 只有在本次程序中,两个才会相等,下面才会执行 main()
阅读全文
posted @ 2020-06-12 18:31 abel2020
阅读(88)
评论(0)
推荐(0)
27 异常传递
摘要: def input_passwd(): pwd=input("请输入密码:") if len(pwd) >=8: return pwd else: # 1 创建异常对象 使用错误信息字符串作为参数:如 密码长度不够 ex=Exception("密码长度不够") #Exception 是py的异常对象
阅读全文
posted @ 2020-06-12 17:23 abel2020
阅读(121)
评论(0)
推荐(0)
26 异常处理
摘要: try: #可能出现错误的代码 num=input(("please input number:")) d except error_code1: # 针对错误类型(最后一行第一个单词),执行如下代码 pass except Exception as err_other: print(err_oth
阅读全文
posted @ 2020-06-12 16:48 abel2020
阅读(113)
评论(0)
推荐(0)
25 面向对象8: 单实例模式
摘要: """类中只有一个对象1 重写new方法 只初始化一次内存2 设置标志位,使init 在多次被执行时,实际代码只被执行一次""" class MusicPlayer(object): instance=None #初始没有对象, 定义类的instance属性,设为空 # new是object类内置的
阅读全文
posted @ 2020-06-12 10:03 abel2020
阅读(120)
评论(0)
推荐(0)
24 面向对象综合1
摘要: class Game: top_score=0 #定义类属性 @classmethod #定义类方法,因为要调用类属性 def show_top_score(cls): print("top score :%s "% cls.top_score) @staticmethod #定义静态方法,什么都不
阅读全文
posted @ 2020-06-12 00:57 abel2020
阅读(81)
评论(0)
推荐(0)
上一页
1
···
4
5
6
7
8
9
10
11
12
···
14
下一页
公告