From c9ba8dd5d5fca2010e4b01d2bbbde756593bcc5c Mon Sep 17 00:00:00 2001 From: TwoWater <347073565@qq.com> Date: Sat, 6 Jul 2019 14:01:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BB=A3=E7=A0=81=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Article/Linux/Linux命令-用户,权限管理模块.md | 38 + Code/Python10Code/.idea/Python10Code.iml | 11 - .../inspectionProfiles/profiles_settings.xml | 7 - Code/Python10Code/.idea/misc.xml | 4 - Code/Python10Code/.idea/modules.xml | 8 - Code/Python10Code/.idea/workspace.xml | 606 ---------------- Code/Python10Code/com/__init__.py | 2 - Code/Python10Code/com/twowater/__init__.py | 2 - Code/Python10Code/com/twowater/mtest1.py | 9 - Code/Python10Code/com/twowater/mtest10.py | 41 -- Code/Python10Code/com/twowater/mtest2.py | 19 - Code/Python10Code/com/twowater/mtest3.py | 16 - Code/Python10Code/com/twowater/mtest4.py | 34 - Code/Python10Code/com/twowater/mtest5.py | 9 - Code/Python10Code/com/twowater/mtest6.py | 38 - Code/Python10Code/com/twowater/mtest7.py | 35 - Code/Python10Code/com/twowater/mtest8.py | 56 -- Code/Python10Code/com/twowater/mtest9.py | 56 -- Code/Python11Code/.idea/Python11Code.iml | 11 - .../inspectionProfiles/profiles_settings.xml | 7 - Code/Python11Code/.idea/misc.xml | 4 - Code/Python11Code/.idea/modules.xml | 8 - Code/Python11Code/.idea/workspace.xml | 513 ------------- Code/Python11Code/com/__init__.py | 2 - Code/Python11Code/com/twowater/__init__.py | 2 - Code/Python11Code/com/twowater/mtest1.py | 13 - Code/Python11Code/com/twowater/mtest2.py | 29 - Code/Python11Code/com/twowater/mtest3.py | 21 - Code/Python11Code/com/twowater/mtest4.py | 15 - Code/Python14Code/.idea/Python14Code.iml | 11 - .../inspectionProfiles/profiles_settings.xml | 7 - Code/Python14Code/.idea/misc.xml | 4 - Code/Python14Code/.idea/modules.xml | 8 - Code/Python14Code/.idea/workspace.xml | 593 --------------- Code/Python14Code/com/__init__.py | 2 - Code/Python14Code/com/twowater/__init__.py | 2 - Code/Python14Code/com/twowater/test1.py | 28 - Code/Python14Code/com/twowater/test2.py | 19 - Code/Python14Code/com/twowater/test3.py | 25 - Code/Python14Code/com/twowater/test4.py | 16 - Code/Python14Code/com/twowater/test5.py | 12 - Code/Python14Code/com/twowater/test6.py | 13 - Code/Python14Code/com/twowater/test7.py | 30 - Code/Python14Code/com/twowater/test8.py | 29 - Code/Python8Code/.idea/Python8Code.iml | 11 - .../inspectionProfiles/profiles_settings.xml | 7 - Code/Python8Code/.idea/misc.xml | 4 - Code/Python8Code/.idea/modules.xml | 8 - Code/Python8Code/.idea/workspace.xml | 574 --------------- Code/Python8Code/com/Learn/__init__.py | 2 - Code/Python8Code/com/Learn/module/__init__.py | 2 - .../Learn/module/nameattributes/__init__.py | 2 - .../__pycache__/lname.cpython-36.pyc | Bin 243 -> 0 bytes .../com/Learn/module/nameattributes/lname.py | 7 - .../Learn/module/nameattributes/user_lname.py | 6 - .../module/privateattributes/__init__.py | 2 - .../module/privateattributes/vip_user.py | 23 - .../com/Learn/module/sys/__init__.py | 2 - .../com/Learn/module/sys/test_sys.py | 6 - Code/Python8Code/com/__init__.py | 2 - Code/Python9Code/.idea/Python9Code.iml | 11 - .../inspectionProfiles/profiles_settings.xml | 7 - Code/Python9Code/.idea/misc.xml | 4 - Code/Python9Code/.idea/modules.xml | 8 - Code/Python9Code/.idea/workspace.xml | 680 ------------------ Code/Python9Code/com/__init__.py | 2 - Code/Python9Code/com/twowater/__init__.py | 2 - Code/Python9Code/com/twowater/mtest0.py | 10 - Code/Python9Code/com/twowater/mtest1.py | 27 - Code/Python9Code/com/twowater/mtest2.py | 17 - Code/Python9Code/com/twowater/mtest3.py | 22 - Code/Python9Code/com/twowater/mtest4.py | 13 - Code/Python9Code/com/twowater/mtest5.py | 33 - Code/Python9Code/com/twowater/mtest6.py | 36 - Code/Python9Code/com/twowater/mtest7.py | 23 - Code/Python9Code/com/twowater/mtest8.py | 27 - Code/Python9Code/com/twowater/mtest9.py | 30 - README.md | 4 +- 78 files changed, 41 insertions(+), 3988 deletions(-) create mode 100644 Article/Linux/Linux命令-用户,权限管理模块.md delete mode 100644 Code/Python10Code/.idea/Python10Code.iml delete mode 100644 Code/Python10Code/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 Code/Python10Code/.idea/misc.xml delete mode 100644 Code/Python10Code/.idea/modules.xml delete mode 100644 Code/Python10Code/.idea/workspace.xml delete mode 100644 Code/Python10Code/com/__init__.py delete mode 100644 Code/Python10Code/com/twowater/__init__.py delete mode 100644 Code/Python10Code/com/twowater/mtest1.py delete mode 100644 Code/Python10Code/com/twowater/mtest10.py delete mode 100644 Code/Python10Code/com/twowater/mtest2.py delete mode 100644 Code/Python10Code/com/twowater/mtest3.py delete mode 100644 Code/Python10Code/com/twowater/mtest4.py delete mode 100644 Code/Python10Code/com/twowater/mtest5.py delete mode 100644 Code/Python10Code/com/twowater/mtest6.py delete mode 100644 Code/Python10Code/com/twowater/mtest7.py delete mode 100644 Code/Python10Code/com/twowater/mtest8.py delete mode 100644 Code/Python10Code/com/twowater/mtest9.py delete mode 100644 Code/Python11Code/.idea/Python11Code.iml delete mode 100644 Code/Python11Code/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 Code/Python11Code/.idea/misc.xml delete mode 100644 Code/Python11Code/.idea/modules.xml delete mode 100644 Code/Python11Code/.idea/workspace.xml delete mode 100644 Code/Python11Code/com/__init__.py delete mode 100644 Code/Python11Code/com/twowater/__init__.py delete mode 100644 Code/Python11Code/com/twowater/mtest1.py delete mode 100644 Code/Python11Code/com/twowater/mtest2.py delete mode 100644 Code/Python11Code/com/twowater/mtest3.py delete mode 100644 Code/Python11Code/com/twowater/mtest4.py delete mode 100644 Code/Python14Code/.idea/Python14Code.iml delete mode 100644 Code/Python14Code/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 Code/Python14Code/.idea/misc.xml delete mode 100644 Code/Python14Code/.idea/modules.xml delete mode 100644 Code/Python14Code/.idea/workspace.xml delete mode 100644 Code/Python14Code/com/__init__.py delete mode 100644 Code/Python14Code/com/twowater/__init__.py delete mode 100644 Code/Python14Code/com/twowater/test1.py delete mode 100644 Code/Python14Code/com/twowater/test2.py delete mode 100644 Code/Python14Code/com/twowater/test3.py delete mode 100644 Code/Python14Code/com/twowater/test4.py delete mode 100644 Code/Python14Code/com/twowater/test5.py delete mode 100644 Code/Python14Code/com/twowater/test6.py delete mode 100644 Code/Python14Code/com/twowater/test7.py delete mode 100644 Code/Python14Code/com/twowater/test8.py delete mode 100644 Code/Python8Code/.idea/Python8Code.iml delete mode 100644 Code/Python8Code/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 Code/Python8Code/.idea/misc.xml delete mode 100644 Code/Python8Code/.idea/modules.xml delete mode 100644 Code/Python8Code/.idea/workspace.xml delete mode 100644 Code/Python8Code/com/Learn/__init__.py delete mode 100644 Code/Python8Code/com/Learn/module/__init__.py delete mode 100644 Code/Python8Code/com/Learn/module/nameattributes/__init__.py delete mode 100644 Code/Python8Code/com/Learn/module/nameattributes/__pycache__/lname.cpython-36.pyc delete mode 100644 Code/Python8Code/com/Learn/module/nameattributes/lname.py delete mode 100644 Code/Python8Code/com/Learn/module/nameattributes/user_lname.py delete mode 100644 Code/Python8Code/com/Learn/module/privateattributes/__init__.py delete mode 100644 Code/Python8Code/com/Learn/module/privateattributes/vip_user.py delete mode 100644 Code/Python8Code/com/Learn/module/sys/__init__.py delete mode 100644 Code/Python8Code/com/Learn/module/sys/test_sys.py delete mode 100644 Code/Python8Code/com/__init__.py delete mode 100644 Code/Python9Code/.idea/Python9Code.iml delete mode 100644 Code/Python9Code/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 Code/Python9Code/.idea/misc.xml delete mode 100644 Code/Python9Code/.idea/modules.xml delete mode 100644 Code/Python9Code/.idea/workspace.xml delete mode 100644 Code/Python9Code/com/__init__.py delete mode 100644 Code/Python9Code/com/twowater/__init__.py delete mode 100644 Code/Python9Code/com/twowater/mtest0.py delete mode 100644 Code/Python9Code/com/twowater/mtest1.py delete mode 100644 Code/Python9Code/com/twowater/mtest2.py delete mode 100644 Code/Python9Code/com/twowater/mtest3.py delete mode 100644 Code/Python9Code/com/twowater/mtest4.py delete mode 100644 Code/Python9Code/com/twowater/mtest5.py delete mode 100644 Code/Python9Code/com/twowater/mtest6.py delete mode 100644 Code/Python9Code/com/twowater/mtest7.py delete mode 100644 Code/Python9Code/com/twowater/mtest8.py delete mode 100644 Code/Python9Code/com/twowater/mtest9.py diff --git a/Article/Linux/Linux命令-用户,权限管理模块.md b/Article/Linux/Linux命令-用户,权限管理模块.md new file mode 100644 index 0000000..fe569e7 --- /dev/null +++ b/Article/Linux/Linux命令-用户,权限管理模块.md @@ -0,0 +1,38 @@ +## 用户,权限管理 + +用户是 Unix/Linux 系统工作中重要的一环,用户管理包括用户与组账号的管理。 + +在 Unix/Linux 系统中,不论是由本机或是远程登录系统,每个系统都必须拥有一个账号,并且对于不同的系统资源拥有不同的使用权限。 + +Unix/Linux 系统中的 root 账号通常用于系统的维护和管理,它对 Unix/Linux 操作系统的所有部分具有不受限制的访问权限。 + +在 Unix/Linux 安装的过程中,系统会自动创建许多用户账号,而这些默认的用户就称为“标准用户”。 + +在大多数版本的 Unix/Linux 中,都不推荐直接使用 root 账号登录系统。 + +#### 1.多用户系统 + +> 什么是多用户呢? + +「多用户」指允许多个用户(逻辑上的账户),同时使用的操作系统或应用软件。 + +而 Linux 就是多用户操作系统,允许多个用户通过远程登录的方式访问一台机器并同时进行使用,相互之间互不影响。 + +> 那我们经常使用的 Windows 是不是多用户操作系统呢? + +Windows 系列的话,Windows 1.x、2.x、3.x(不含NT 3.x)、9x、Me 均为单用户操作系统,其中 9x 虽然有多用户的雏形但基本形同虚设,Windows Me 是最后一个非 NT 内核的 Windows 系统,同样不具备实用性的多用户设计。 + +有人会问, Windows 不是可以创建多个账号吗?为什么不是多用户操作系统呢? + +其实 Windows 的多用户不是真正的多用户,就好比你在家里远程登录了你公司的电脑,你公司的电脑会立刻进入到锁屏状态,而且被人是不可以操作的。这就说明不能多账号同时操作一台电脑了。 + + + + + + + + + + + diff --git a/Code/Python10Code/.idea/Python10Code.iml b/Code/Python10Code/.idea/Python10Code.iml deleted file mode 100644 index d8e9a18..0000000 --- a/Code/Python10Code/.idea/Python10Code.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python10Code/.idea/inspectionProfiles/profiles_settings.xml b/Code/Python10Code/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index c23ecac..0000000 --- a/Code/Python10Code/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python10Code/.idea/misc.xml b/Code/Python10Code/.idea/misc.xml deleted file mode 100644 index dac3415..0000000 --- a/Code/Python10Code/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python10Code/.idea/modules.xml b/Code/Python10Code/.idea/modules.xml deleted file mode 100644 index f89682d..0000000 --- a/Code/Python10Code/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Code/Python10Code/.idea/workspace.xml b/Code/Python10Code/.idea/workspace.xml deleted file mode 100644 index 5438540..0000000 --- a/Code/Python10Code/.idea/workspace.xml +++ /dev/null @@ -1,606 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1501589773782 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python10Code/com/__init__.py b/Code/Python10Code/com/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python10Code/com/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python10Code/com/twowater/__init__.py b/Code/Python10Code/com/twowater/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python10Code/com/twowater/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python10Code/com/twowater/mtest1.py b/Code/Python10Code/com/twowater/mtest1.py deleted file mode 100644 index 9280982..0000000 --- a/Code/Python10Code/com/twowater/mtest1.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - def __init__(self, name, age): - self.name = name; - self.age = age; - -user=User('两点水',23) diff --git a/Code/Python10Code/com/twowater/mtest10.py b/Code/Python10Code/com/twowater/mtest10.py deleted file mode 100644 index e64448f..0000000 --- a/Code/Python10Code/com/twowater/mtest10.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class Number(object): - def __init__(self, value): - self.value = value - - def __eq__(self, other): - print('__eq__') - return self.value == other.value - - def __ne__(self, other): - print('__ne__') - return self.value != other.value - - def __lt__(self, other): - print('__lt__') - return self.value < other.value - - def __gt__(self, other): - print('__gt__') - return self.value > other.value - - def __le__(self, other): - print('__le__') - return self.value <= other.value - - def __ge__(self, other): - print('__ge__') - return self.value >= other.value - - -if __name__ == '__main__': - num1 = Number(2) - num2 = Number(3) - print('num1 == num2 ? --------> {} \n'.format(num1 == num2)) - print('num1 != num2 ? --------> {} \n'.format(num1 == num2)) - print('num1 < num2 ? --------> {} \n'.format(num1 < num2)) - print('num1 > num2 ? --------> {} \n'.format(num1 > num2)) - print('num1 <= num2 ? --------> {} \n'.format(num1 <= num2)) - print('num1 >= num2 ? --------> {} \n'.format(num1 >= num2)) diff --git a/Code/Python10Code/com/twowater/mtest2.py b/Code/Python10Code/com/twowater/mtest2.py deleted file mode 100644 index 0252fa2..0000000 --- a/Code/Python10Code/com/twowater/mtest2.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - def __new__(cls, *args, **kwargs): - # 打印 __new__方法中的相关信息 - print('调用了 def __new__ 方法') - print(args) - # 最后返回父类的方法 - return super(User, cls).__new__(cls) - - def __init__(self, name, age): - print('调用了 def __init__ 方法') - self.name = name - self.age = age - - -if __name__ == '__main__': - usr = User('两点水', 23) diff --git a/Code/Python10Code/com/twowater/mtest3.py b/Code/Python10Code/com/twowater/mtest3.py deleted file mode 100644 index 41cc076..0000000 --- a/Code/Python10Code/com/twowater/mtest3.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - - name='' - - def __setattr__(self, name, value): - # 每一次属性赋值时, __setattr__都会被调用,因此不断调用自身导致无限递归了 - # 会造成程序奔溃 - self.name = value - - -if __name__ == '__main__': - user = User() - user.name='两点水' diff --git a/Code/Python10Code/com/twowater/mtest4.py b/Code/Python10Code/com/twowater/mtest4.py deleted file mode 100644 index 5ef4e44..0000000 --- a/Code/Python10Code/com/twowater/mtest4.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - def __getattr__(self, name): - print('调用了 __getattr__ 方法') - return super(User, self).__getattr__(name) - - def __setattr__(self, name, value): - print('调用了 __setattr__ 方法') - return super(User, self).__setattr__(name, value) - - def __delattr__(self, name): - print('调用了 __delattr__ 方法') - return super(User, self).__delattr__(name) - - def __getattribute__(self, name): - print('调用了 __getattribute__ 方法') - return super(User, self).__getattribute__(name) - - -if __name__ == '__main__': - user = User() - # 设置属性值,会调用 __setattr__ - user.attr1 = True - # 属性存在,只有__getattribute__调用 - user.attr1 - try: - # 属性不存在, 先调用__getattribute__, 后调用__getattr__ - user.attr2 - except AttributeError: - pass - # __delattr__调用 - del user.attr1 diff --git a/Code/Python10Code/com/twowater/mtest5.py b/Code/Python10Code/com/twowater/mtest5.py deleted file mode 100644 index 8437539..0000000 --- a/Code/Python10Code/com/twowater/mtest5.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - pass - - -if __name__ == '__main__': - print(dir(User())) diff --git a/Code/Python10Code/com/twowater/mtest6.py b/Code/Python10Code/com/twowater/mtest6.py deleted file mode 100644 index eb3d020..0000000 --- a/Code/Python10Code/com/twowater/mtest6.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - def __init__(self, name='两点水', sex='男'): - self.sex = sex - self.name = name - - def __get__(self, obj, objtype): - print('获取 name 值') - return self.name - - def __set__(self, obj, val): - print('设置 name 值') - self.name = val - - -class MyClass(object): - x = User('两点水', '男') - y = 5 - - -if __name__ == '__main__': - m = MyClass() - print(m.x) - - print('\n') - - m.x = '三点水' - print(m.x) - - print('\n') - - print(m.x) - - print('\n') - - print(m.y) diff --git a/Code/Python10Code/com/twowater/mtest7.py b/Code/Python10Code/com/twowater/mtest7.py deleted file mode 100644 index fcb4642..0000000 --- a/Code/Python10Code/com/twowater/mtest7.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - - -class Meter(object): - def __init__(self, value=0.0): - self.value = float(value) - - def __get__(self, instance, owner): - return self.value - - def __set__(self, instance, value): - self.value = float(value) - - -class Foot(object): - def __get__(self, instance, owner): - return instance.meter * 3.2808 - - def __set__(self, instance, value): - instance.meter = float(value) / 3.2808 - - -class Distance(object): - meter = Meter() - foot = Foot() - - -if __name__ == '__main__': - d = Distance() - print(d.meter, d.foot) - d.meter = 1 - print(d.meter, d.foot) - d.meter = 2 - print(d.meter, d.foot) diff --git a/Code/Python10Code/com/twowater/mtest8.py b/Code/Python10Code/com/twowater/mtest8.py deleted file mode 100644 index 0ce9676..0000000 --- a/Code/Python10Code/com/twowater/mtest8.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class FunctionalList: - ''' 实现了内置类型list的功能,并丰富了一些其他方法: head, tail, init, last, drop, take ''' - - def __init__(self, values=None): - if values is None: - self.values = [] - else: - self.values = values - - def __len__(self): - return len(self.values) - - def __getitem__(self, key): - return self.values[key] - - def __setitem__(self, key, value): - self.values[key] = value - - def __delitem__(self, key): - del self.values[key] - - def __iter__(self): - return iter(self.values) - - def __reversed__(self): - return FunctionalList(reversed(self.values)) - - def append(self, value): - self.values.append(value) - - def head(self): - # 获取第一个元素 - return self.values[0] - - def tail(self): - # 获取第一个元素之后的所有元素 - return self.values[1:] - - def init(self): - # 获取最后一个元素之前的所有元素 - return self.values[:-1] - - def last(self): - # 获取最后一个元素 - return self.values[-1] - - def drop(self, n): - # 获取所有元素,除了前N个 - return self.values[n:] - - def take(self, n): - # 获取前N个元素 - return self.values[:n] diff --git a/Code/Python10Code/com/twowater/mtest9.py b/Code/Python10Code/com/twowater/mtest9.py deleted file mode 100644 index b40443d..0000000 --- a/Code/Python10Code/com/twowater/mtest9.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class FunctionalList: - ''' 实现了内置类型list的功能,并丰富了一些其他方法: head, tail, init, last, drop, take''' - - def __init__(self, values=None): - if values is None: - self.values = [] - else: - self.values = values - - def __len__(self): - return len(self.values) - - def __getitem__(self, key): - return self.values[key] - - def __setitem__(self, key, value): - self.values[key] = value - - def __delitem__(self, key): - del self.values[key] - - def __iter__(self): - return iter(self.values) - - def __reversed__(self): - return FunctionalList(reversed(self.values)) - - def append(self, value): - self.values.append(value) - - def head(self): - # 获取第一个元素 - return self.values[0] - - def tail(self): - # 获取第一个元素之后的所有元素 - return self.values[1:] - - def init(self): - # 获取最后一个元素之前的所有元素 - return self.values[:-1] - - def last(self): - # 获取最后一个元素 - return self.values[-1] - - def drop(self, n): - # 获取所有元素,除了前N个 - return self.values[n:] - - def take(self, n): - # 获取前N个元素 - return self.values[:n] diff --git a/Code/Python11Code/.idea/Python11Code.iml b/Code/Python11Code/.idea/Python11Code.iml deleted file mode 100644 index 6711606..0000000 --- a/Code/Python11Code/.idea/Python11Code.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python11Code/.idea/inspectionProfiles/profiles_settings.xml b/Code/Python11Code/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index c23ecac..0000000 --- a/Code/Python11Code/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python11Code/.idea/misc.xml b/Code/Python11Code/.idea/misc.xml deleted file mode 100644 index dac3415..0000000 --- a/Code/Python11Code/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python11Code/.idea/modules.xml b/Code/Python11Code/.idea/modules.xml deleted file mode 100644 index b47c986..0000000 --- a/Code/Python11Code/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Code/Python11Code/.idea/workspace.xml b/Code/Python11Code/.idea/workspace.xml deleted file mode 100644 index d4b50b8..0000000 --- a/Code/Python11Code/.idea/workspace.xml +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1503024519578 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python11Code/com/__init__.py b/Code/Python11Code/com/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python11Code/com/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python11Code/com/twowater/__init__.py b/Code/Python11Code/com/twowater/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python11Code/com/twowater/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python11Code/com/twowater/mtest1.py b/Code/Python11Code/com/twowater/mtest1.py deleted file mode 100644 index ed390b0..0000000 --- a/Code/Python11Code/com/twowater/mtest1.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -from enum import Enum - -Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) - -# 遍历枚举类型 -for name, member in Month.__members__.items(): - print(name, '---------', member, '----------', member.value) - -# 直接引用一个常量 -print('\n', Month.Jan) diff --git a/Code/Python11Code/com/twowater/mtest2.py b/Code/Python11Code/com/twowater/mtest2.py deleted file mode 100644 index 84bf5af..0000000 --- a/Code/Python11Code/com/twowater/mtest2.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- -from enum import Enum, unique - -Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) - - -# @unique 装饰器可以帮助我们检查保证没有重复值 -@unique -class Month(Enum): - Jan = 'January' - Feb = 'February' - Mar = 'March' - Apr = 'April' - May = 'May' - Jun = 'June' - Jul = 'July' - Aug = 'August' - Sep = 'September ' - Oct = 'October' - Nov = 'November' - Dec = 'December' - - -if __name__ == '__main__': - print(Month.Jan, '----------', - Month.Jan.name, '----------', Month.Jan.value) - for name, member in Month.__members__.items(): - print(name, '----------', member, '----------', member.value) diff --git a/Code/Python11Code/com/twowater/mtest3.py b/Code/Python11Code/com/twowater/mtest3.py deleted file mode 100644 index e57024b..0000000 --- a/Code/Python11Code/com/twowater/mtest3.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- -from enum import Enum - - -class User(Enum): - Twowater = 98 - Liangdianshui = 30 - Tom = 12 - - -Twowater = User.Twowater -Liangdianshui = User.Liangdianshui - -print(Twowater == Liangdianshui, Twowater == User.Twowater) -print(Twowater is Liangdianshui, Twowater is User.Twowater) - -try: - print('\n'.join(' ' + s.name for s in sorted(User))) -except TypeError as err: - print(' Error : {}'.format(err)) diff --git a/Code/Python11Code/com/twowater/mtest4.py b/Code/Python11Code/com/twowater/mtest4.py deleted file mode 100644 index 6ff64bf..0000000 --- a/Code/Python11Code/com/twowater/mtest4.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- -import enum - - -class User(enum.IntEnum): - Twowater = 98 - Liangdianshui = 30 - Tom = 12 - - -try: - print('\n'.join(s.name for s in sorted(User))) -except TypeError as err: - print(' Error : {}'.format(err)) diff --git a/Code/Python14Code/.idea/Python14Code.iml b/Code/Python14Code/.idea/Python14Code.iml deleted file mode 100644 index 6711606..0000000 --- a/Code/Python14Code/.idea/Python14Code.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python14Code/.idea/inspectionProfiles/profiles_settings.xml b/Code/Python14Code/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index c23ecac..0000000 --- a/Code/Python14Code/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python14Code/.idea/misc.xml b/Code/Python14Code/.idea/misc.xml deleted file mode 100644 index dac3415..0000000 --- a/Code/Python14Code/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python14Code/.idea/modules.xml b/Code/Python14Code/.idea/modules.xml deleted file mode 100644 index 462b327..0000000 --- a/Code/Python14Code/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Code/Python14Code/.idea/workspace.xml b/Code/Python14Code/.idea/workspace.xml deleted file mode 100644 index 7a31079..0000000 --- a/Code/Python14Code/.idea/workspace.xml +++ /dev/null @@ -1,593 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1513907070570 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python14Code/com/__init__.py b/Code/Python14Code/com/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python14Code/com/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python14Code/com/twowater/__init__.py b/Code/Python14Code/com/twowater/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python14Code/com/twowater/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python14Code/com/twowater/test1.py b/Code/Python14Code/com/twowater/test1.py deleted file mode 100644 index dcf8a2f..0000000 --- a/Code/Python14Code/com/twowater/test1.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -# 设定一个常量 -a = '两点水|twowater|liangdianshui|草根程序员|ReadingWithU' - -# 判断是否有 “两点水” 这个字符串,使用 PY 自带函数 - -print('a 是否含有“两点水”这个字符串:{0}'.format(a.index('两点水') > -1)) -print('a 是否含有“两点水”这个字符串:{0}'.format('两点水' in a)) - -# 正则表达式 - -findall = re.findall('两点水', a) -print(findall) - -if len(findall) > 0: - print('a 含有“两点水”这个字符串') -else: - print('a 不含有“两点水”这个字符串') - -# 选择 a 里面的所有小写英文字母 - -re_findall = re.findall('[a-z]', a) - -print(re_findall) diff --git a/Code/Python14Code/com/twowater/test2.py b/Code/Python14Code/com/twowater/test2.py deleted file mode 100644 index 0416083..0000000 --- a/Code/Python14Code/com/twowater/test2.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -a = 'uav,ubv,ucv,uwv,uzv,ucv,uov' - -# 字符集 - -# 取 u 和 v 中间是 a 或 b 或 c 的字符 -findall = re.findall('u[abc]v', a) -print(findall) -# 如果是连续的字母,数字可以使用 - 来代替 -l = re.findall('u[a-c]v', a) -print(l) - -# 取 u 和 v 中间不是 a 或 b 或 c 的字符 -re_findall = re.findall('u[^abc]v', a) -print(re_findall) diff --git a/Code/Python14Code/com/twowater/test3.py b/Code/Python14Code/com/twowater/test3.py deleted file mode 100644 index bbae7e0..0000000 --- a/Code/Python14Code/com/twowater/test3.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -a = 'uav_ubv_ucv_uwv_uzv_ucv_uov&123-456-789' - -# 概括字符集 - -# \d 相当于 [0-9] ,匹配所有数字字符 -# \D 相当于 [^0-9] , 匹配所有非数字字符 -findall1 = re.findall('\d', a) -findall2 = re.findall('[0-9]', a) -findall3 = re.findall('\D', a) -findall4 = re.findall('[^0-9]', a) -print(findall1) -print(findall2) -print(findall3) -print(findall4) - -# \w 匹配包括下划线的任何单词字符,等价于 [A-Za-z0-9_] -findall5 = re.findall('\w', a) -findall6 = re.findall('[A-Za-z0-9_]', a) -print(findall5) -print(findall6) diff --git a/Code/Python14Code/com/twowater/test4.py b/Code/Python14Code/com/twowater/test4.py deleted file mode 100644 index b234f3e..0000000 --- a/Code/Python14Code/com/twowater/test4.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -a = 'java*&39android##@@python' - -# 数量词 - -findall = re.findall('[a-z]{4,7}', a) -print(findall) - -# 贪婪与非贪婪 - -re_findall = re.findall('[a-z]{4,7}?', a) -print(re_findall) diff --git a/Code/Python14Code/com/twowater/test5.py b/Code/Python14Code/com/twowater/test5.py deleted file mode 100644 index 9a70011..0000000 --- a/Code/Python14Code/com/twowater/test5.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -a = '347073565' - -# 边界匹配符 - -findall = re.findall('\d{6}565$', a) - -print(findall) diff --git a/Code/Python14Code/com/twowater/test6.py b/Code/Python14Code/com/twowater/test6.py deleted file mode 100644 index 57967fe..0000000 --- a/Code/Python14Code/com/twowater/test6.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -a = 'pythonpythonpython' - -# 组 - -findall = re.findall('(python){3}', a) -print(findall) - - diff --git a/Code/Python14Code/com/twowater/test7.py b/Code/Python14Code/com/twowater/test7.py deleted file mode 100644 index a973ec5..0000000 --- a/Code/Python14Code/com/twowater/test7.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -import re - -a = 'Python*Android*Java-888' - -# 把字符串中的 * 字符替换成 & 字符 -sub1 = re.sub('\*', '&', a) -print(sub1) - -# 把字符串中的第一个 * 字符替换成 & 字符 -sub2 = re.sub('\*', '&', a, 1) -print(sub2) - - -# 把字符串中的 * 字符替换成 & 字符,把字符 - 换成 | - -# 1、先定义一个函数 -def convert(value): - group = value.group() - if (group == '*'): - return '&' - elif (group == '-'): - return '|' - - -# 第二个参数,要替换的字符可以为一个函数 -sub3 = re.sub('[\*-]', convert, a) -print(sub3) diff --git a/Code/Python14Code/com/twowater/test8.py b/Code/Python14Code/com/twowater/test8.py deleted file mode 100644 index 8dddad1..0000000 --- a/Code/Python14Code/com/twowater/test8.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -# 提取图片的地址 - -import re - -a = '' - -# 使用 re.search -search = re.search('', a) -# group(0) 是一个完整的分组 -print(search.group(0)) -print(search.group(1)) - -# 使用 re.findall -findall = re.findall('', a) -print(findall) - -# 多个分组的使用(比如我们需要提取 img 字段和图片地址字段) -re_search = re.search('<(.*) src="(.*)">', a) -# 打印 img -print(re_search.group(1)) -# 打印图片地址 -print(re_search.group(2)) -# 打印 img 和图片地址,以元祖的形式 -print(re_search.group(1, 2)) -# 或者使用 groups -print(re_search.groups()) diff --git a/Code/Python8Code/.idea/Python8Code.iml b/Code/Python8Code/.idea/Python8Code.iml deleted file mode 100644 index 6711606..0000000 --- a/Code/Python8Code/.idea/Python8Code.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python8Code/.idea/inspectionProfiles/profiles_settings.xml b/Code/Python8Code/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index c23ecac..0000000 --- a/Code/Python8Code/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python8Code/.idea/misc.xml b/Code/Python8Code/.idea/misc.xml deleted file mode 100644 index dac3415..0000000 --- a/Code/Python8Code/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python8Code/.idea/modules.xml b/Code/Python8Code/.idea/modules.xml deleted file mode 100644 index de5ca31..0000000 --- a/Code/Python8Code/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Code/Python8Code/.idea/workspace.xml b/Code/Python8Code/.idea/workspace.xml deleted file mode 100644 index 69dcbd3..0000000 --- a/Code/Python8Code/.idea/workspace.xml +++ /dev/null @@ -1,574 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1499686684711 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python8Code/com/Learn/__init__.py b/Code/Python8Code/com/Learn/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python8Code/com/Learn/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python8Code/com/Learn/module/__init__.py b/Code/Python8Code/com/Learn/module/__init__.py deleted file mode 100644 index d7df38c..0000000 --- a/Code/Python8Code/com/Learn/module/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python8Code/com/Learn/module/nameattributes/__init__.py b/Code/Python8Code/com/Learn/module/nameattributes/__init__.py deleted file mode 100644 index 24ba15a..0000000 --- a/Code/Python8Code/com/Learn/module/nameattributes/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python8Code/com/Learn/module/nameattributes/__pycache__/lname.cpython-36.pyc b/Code/Python8Code/com/Learn/module/nameattributes/__pycache__/lname.cpython-36.pyc deleted file mode 100644 index baf0bfc4a3aca2ff761feed5c04fb679f5fac92c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 243 zcmXr!<>gvBD><@(fq~&M5W@izkmUfx#d1I*l_7;8o2f`Bl`(~}nURqpj|0eJ0ASzJ<-Sdw29pES&RGQe%?yb7Oo` x6N~a - - - - - - - - - \ No newline at end of file diff --git a/Code/Python9Code/.idea/inspectionProfiles/profiles_settings.xml b/Code/Python9Code/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index c23ecac..0000000 --- a/Code/Python9Code/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python9Code/.idea/misc.xml b/Code/Python9Code/.idea/misc.xml deleted file mode 100644 index dac3415..0000000 --- a/Code/Python9Code/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Code/Python9Code/.idea/modules.xml b/Code/Python9Code/.idea/modules.xml deleted file mode 100644 index 0a15fc1..0000000 --- a/Code/Python9Code/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Code/Python9Code/.idea/workspace.xml b/Code/Python9Code/.idea/workspace.xml deleted file mode 100644 index 5177d29..0000000 --- a/Code/Python9Code/.idea/workspace.xml +++ /dev/null @@ -1,680 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1500999902927 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Code/Python9Code/com/__init__.py b/Code/Python9Code/com/__init__.py deleted file mode 100644 index 24ba15a..0000000 --- a/Code/Python9Code/com/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python9Code/com/twowater/__init__.py b/Code/Python9Code/com/twowater/__init__.py deleted file mode 100644 index 24ba15a..0000000 --- a/Code/Python9Code/com/twowater/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- \ No newline at end of file diff --git a/Code/Python9Code/com/twowater/mtest0.py b/Code/Python9Code/com/twowater/mtest0.py deleted file mode 100644 index 6d91e42..0000000 --- a/Code/Python9Code/com/twowater/mtest0.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class Test: - def prt(self): - print(self) - print(self.__class__) - -t = Test() -t.prt() \ No newline at end of file diff --git a/Code/Python9Code/com/twowater/mtest1.py b/Code/Python9Code/com/twowater/mtest1.py deleted file mode 100644 index 2330058..0000000 --- a/Code/Python9Code/com/twowater/mtest1.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -# 旧式类 -class OldClass: - def __init__(self, account, name): - self.account = account; - self.name = name; - - -# 新式类 -class NewClass(object): - def __init__(self, account, name): - self.account = account; - self.name = name; - - -if __name__ == '__main__': - old_class = OldClass(111111, 'OldClass') - print(old_class) - print(type(old_class)) - print(dir(old_class)) - print('\n') - new_class=NewClass(222222,'NewClass') - print(new_class) - print(type(new_class)) - print(dir(new_class)) diff --git a/Code/Python9Code/com/twowater/mtest2.py b/Code/Python9Code/com/twowater/mtest2.py deleted file mode 100644 index b320ac3..0000000 --- a/Code/Python9Code/com/twowater/mtest2.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -class UserInfo(object): - name = '两点水' - - -class UserInfo(object): - def __init__(self, name): - self.name = name - - -class UserInfo(object): - def __init__(self, name, age, account): - self.name = name - self._age = age - self.__account = account diff --git a/Code/Python9Code/com/twowater/mtest3.py b/Code/Python9Code/com/twowater/mtest3.py deleted file mode 100644 index 5ae7048..0000000 --- a/Code/Python9Code/com/twowater/mtest3.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -class UserInfo(object): - def __init__(self, name, age, account): - self.name = name - self._age = age - self.__account = account - - def get_account(self): - return self.__account - - -if __name__ == '__main__': - userInfo = UserInfo('两点水', 23, 347073565); - # 打印所有属性 - print(dir(userInfo)) - # 打印构造函数中的属性 - print(userInfo.__dict__) - print(userInfo.get_account()) - # 用于验证双下划线是否是真正的私有属性 - print(userInfo._UserInfo__account) diff --git a/Code/Python9Code/com/twowater/mtest4.py b/Code/Python9Code/com/twowater/mtest4.py deleted file mode 100644 index d7d0d49..0000000 --- a/Code/Python9Code/com/twowater/mtest4.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -class User(object): - def upgrade(self): - pass - - def _buy_equipment(self): - pass - - def __pk(self): - pass - diff --git a/Code/Python9Code/com/twowater/mtest5.py b/Code/Python9Code/com/twowater/mtest5.py deleted file mode 100644 index 75736fb..0000000 --- a/Code/Python9Code/com/twowater/mtest5.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -class UserInfo(object): - lv = 5 - - def __init__(self, name, age, account): - self.name = name - self._age = age - self.__account = account - - def get_account(self): - return self.__account - - @classmethod - def get_name(cls): - return cls.lv - - @property - def get_age(self): - return self._age - - -if __name__ == '__main__': - userInfo = UserInfo('两点水', 23, 347073565); - # 打印所有属性 - print(dir(userInfo)) - # 打印构造函数中的属性 - print(userInfo.__dict__) - # 直接使用类名类调用,而不是某个对象 - print(UserInfo.lv) - # 像访问属性一样调用方法(注意看get_age是没有括号的) - print(userInfo.get_age) diff --git a/Code/Python9Code/com/twowater/mtest6.py b/Code/Python9Code/com/twowater/mtest6.py deleted file mode 100644 index 12474fa..0000000 --- a/Code/Python9Code/com/twowater/mtest6.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class UserInfo(object): - lv = 5 - - def __init__(self, name, age, account): - self.name = name - self._age = age - self.__account = account - - def get_account(self): - return self.__account - - @classmethod - def get_name(cls): - return cls.lv - - @property - def get_age(self): - return self._age - - -class UserInfo2(UserInfo): - def __init__(self, name, age, account, sex): - super(UserInfo2, self).__init__(name, age, account) - self.sex = sex; - - -if __name__ == '__main__': - userInfo2 = UserInfo2('两点水', 23, 347073565, '男'); - # 打印所有属性 - print(dir(userInfo2)) - # 打印构造函数中的属性 - print(userInfo2.__dict__) - print(UserInfo2.get_name()) diff --git a/Code/Python9Code/com/twowater/mtest7.py b/Code/Python9Code/com/twowater/mtest7.py deleted file mode 100644 index 9d6b56a..0000000 --- a/Code/Python9Code/com/twowater/mtest7.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -class UserInfo(object): - lv = 5 - - def __init__(self, name, age, account): - self.name = name - self._age = age - self.__account = account - - def get_account(self): - return self.__account - - -class UserInfo2(UserInfo): - pass - - -if __name__ == '__main__': - userInfo2 = UserInfo2('两点水', 23, 347073565); - print(userInfo2.get_account()) - diff --git a/Code/Python9Code/com/twowater/mtest8.py b/Code/Python9Code/com/twowater/mtest8.py deleted file mode 100644 index 1289281..0000000 --- a/Code/Python9Code/com/twowater/mtest8.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User1(object): - pass - - -class User2(User1): - pass - - -class User3(User2): - pass - - -if __name__ == '__main__': - user1 = User1() - user2 = User2() - user3 = User3() - # isinstance()就可以告诉我们,一个对象是否是某种类型 - print(isinstance(user3, User2)) - print(isinstance(user3, User1)) - print(isinstance(user3, User3)) - # 基本类型也可以用isinstance()判断 - print(isinstance('两点水', str)) - print(isinstance(347073565, int)) - print(isinstance(347073565, str)) diff --git a/Code/Python9Code/com/twowater/mtest9.py b/Code/Python9Code/com/twowater/mtest9.py deleted file mode 100644 index f84240b..0000000 --- a/Code/Python9Code/com/twowater/mtest9.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: UTF-8 -*- - -class User(object): - def __init__(self, name): - self.name = name - - def printUser(self): - print('Hello !' + self.name) - - -class UserVip(User): - def printUser(self): - print('Hello ! 尊敬的Vip用户:' + self.name) - - -class UserGeneral(User): - def printUser(self): - print('Hello ! 尊敬的用户:' + self.name) - - -def printUserInfo(user): - user.printUser() - - -if __name__ == '__main__': - userVip = UserVip('两点水') - printUserInfo(userVip) - userGeneral = UserGeneral('水水水') - printUserInfo(userGeneral) diff --git a/README.md b/README.md index 8873ea1..953c8b7 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ IT 行业相对于一般传统行业,发展更新速度更快,一旦停止 Python 下有许多款不同的 Web 框架。Django 是重量级选手中最有代表性的一位。许多成功的网站和 APP 都基于 Django。 -如果对自己的基础有点信息的童鞋,可以尝试通过国外的 ![Django 博客从搭建到部署系列教程](https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html) 进行入门,这个教程讲的非常的详细,而且还有很多有趣的配图。不过可能因为墙的原因,很多人会访问不到,就算访问到了,也因为是英语的,不会进行耐心的阅读学习。因此我打算翻译这个教程。 +如果对自己的基础有点信息的童鞋,可以尝试通过国外的 [Django 博客从搭建到部署系列教程](https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html) 进行入门,这个教程讲的非常的详细,而且还有很多有趣的配图。不过可能因为墙的原因,很多人会访问不到,就算访问到了,也因为是英语的,不会进行耐心的阅读学习。因此我打算翻译这个教程。 * [一个完整的初学者指南Django-part1](/Article/django/一个完整的初学者指南Django-part1.md) * [一个完整的初学者指南Django-part2](/Article/django/一个完整的初学者指南Django-part2.md) @@ -136,3 +136,5 @@ Python 下有许多款不同的 Web 框架。Django 是重量级选手中最有 持续更新.... + +