python
三十而学
c++入门
展开
-
pyhon常用内建模块及第三方模块
pyhon常用内建模块即第三方模块datetimecollectionsbase64hashlib、hmacitertoolcontextliburllibxmlpillowrequestchardetpsutildatetime>>> from datetime import datetime>>> datetime.now()datetime.datetime(2020, 8, 14, 17, 0, 5, 815305)>>> dateti原创 2020-08-14 21:06:26 · 117 阅读 · 0 评论 -
python正则表达式re
python正则表达式re重要的函数compile(pattern[, flags]) 根据包含正则表达式的字符串创建模式对象,提高匹配效率,search match 均在内部进行了compile转换;search(pattern, string[, flags]) 在字符串中查找模式 ,返回第一个查找的子串的MatchObject;match(pattern, string[, flags]) 在字符串开头匹配模式 ,忽略字符串多余的尾部,若要全匹配,模式添加$,表示结尾;split(pat原创 2020-08-12 10:08:13 · 122 阅读 · 0 评论 -
python基础学习(第二天)
python基础学习(第二天)函数callable(x)判断x是否是可调用对象类双下划线打头的属性或者方法为私有_func();下划线加类名加私有方法,即可访问私有方法class.Class__func()名词: 超类—基类如果你有一个类,并想知道它的基类,可访问其特殊属性__bases同样,要确定对象是否是特定类的实例,可使用isinstance。多重继承,第一个超类覆盖后面超类的相同方法hasattr(class,func)callable(getattr(class,fun原创 2020-08-11 11:55:38 · 118 阅读 · 0 评论 -
python基础学习(第一天)(二)
python基础学习(第一天)(二)字符串#自动编号>>> "{foo} {} {bar} {}".format(1, 2, bar=4, foo=3) '3 1 4 2' #手动编号>>> "{foo} {1} {bar} {0}".format(1, 2, bar=4, foo=3) '3 2 4 1'#访问组成>>> fullname = ["Alfred", "Smoketoomuch"] >>> "Mr原创 2020-08-10 17:04:12 · 97 阅读 · 0 评论 -
python基础学习(第一天)
python基础学习(第一天)str, repr, r>>> print(repr("Hello,\nworld!")) 'Hello,\nworld!' >>> print(str("Hello,\nworld!")) Hello, world! str将值转化为用户看懂的字符串,repr用以表示表达式的值。>>> print(r"hello,\n world")hello,\n world>>> print原创 2020-08-10 11:20:38 · 148 阅读 · 0 评论