Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
Python
提交
278330d5
P
Python
项目概览
OpenDocCN
/
Python
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Python
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
278330d5
编写于
7月 31, 2017
作者:
T
twowater
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Signed-off-by: twowater <347073565@qq.com>
Python 9 代码
上级
e5face5d
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
952 addition
and
0 deletion
+952
-0
Code/Python9Code/.idea/Python9Code.iml
Code/Python9Code/.idea/Python9Code.iml
+11
-0
Code/Python9Code/.idea/inspectionProfiles/profiles_settings.xml
...ython9Code/.idea/inspectionProfiles/profiles_settings.xml
+7
-0
Code/Python9Code/.idea/misc.xml
Code/Python9Code/.idea/misc.xml
+4
-0
Code/Python9Code/.idea/modules.xml
Code/Python9Code/.idea/modules.xml
+8
-0
Code/Python9Code/.idea/workspace.xml
Code/Python9Code/.idea/workspace.xml
+680
-0
Code/Python9Code/com/__init__.py
Code/Python9Code/com/__init__.py
+2
-0
Code/Python9Code/com/twowater/__init__.py
Code/Python9Code/com/twowater/__init__.py
+2
-0
Code/Python9Code/com/twowater/mtest0.py
Code/Python9Code/com/twowater/mtest0.py
+10
-0
Code/Python9Code/com/twowater/mtest1.py
Code/Python9Code/com/twowater/mtest1.py
+27
-0
Code/Python9Code/com/twowater/mtest2.py
Code/Python9Code/com/twowater/mtest2.py
+17
-0
Code/Python9Code/com/twowater/mtest3.py
Code/Python9Code/com/twowater/mtest3.py
+22
-0
Code/Python9Code/com/twowater/mtest4.py
Code/Python9Code/com/twowater/mtest4.py
+13
-0
Code/Python9Code/com/twowater/mtest5.py
Code/Python9Code/com/twowater/mtest5.py
+33
-0
Code/Python9Code/com/twowater/mtest6.py
Code/Python9Code/com/twowater/mtest6.py
+36
-0
Code/Python9Code/com/twowater/mtest7.py
Code/Python9Code/com/twowater/mtest7.py
+23
-0
Code/Python9Code/com/twowater/mtest8.py
Code/Python9Code/com/twowater/mtest8.py
+27
-0
Code/Python9Code/com/twowater/mtest9.py
Code/Python9Code/com/twowater/mtest9.py
+30
-0
未找到文件。
Code/Python9Code/.idea/Python9Code.iml
0 → 100644
浏览文件 @
278330d5
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
<component
name=
"TestRunnerService"
>
<option
name=
"PROJECT_TEST_RUNNER"
value=
"Unittests"
/>
</component>
</module>
\ No newline at end of file
Code/Python9Code/.idea/inspectionProfiles/profiles_settings.xml
0 → 100644
浏览文件 @
278330d5
<component
name=
"InspectionProjectProfileManager"
>
<settings>
<option
name=
"useProjectProfile"
value=
"false"
/>
<option
name=
"USE_PROJECT_PROFILE"
value=
"false"
/>
<version
value=
"1.0"
/>
</settings>
</component>
\ No newline at end of file
Code/Python9Code/.idea/misc.xml
0 → 100644
浏览文件 @
278330d5
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6.1 (C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe)"
project-jdk-type=
"Python SDK"
/>
</project>
\ No newline at end of file
Code/Python9Code/.idea/modules.xml
0 → 100644
浏览文件 @
278330d5
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/Python9Code.iml"
filepath=
"$PROJECT_DIR$/.idea/Python9Code.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
Code/Python9Code/.idea/workspace.xml
0 → 100644
浏览文件 @
278330d5
此差异已折叠。
点击以展开。
Code/Python9Code/com/__init__.py
0 → 100644
浏览文件 @
278330d5
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
\ No newline at end of file
Code/Python9Code/com/twowater/__init__.py
0 → 100644
浏览文件 @
278330d5
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
\ No newline at end of file
Code/Python9Code/com/twowater/mtest0.py
0 → 100644
浏览文件 @
278330d5
#!/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
Code/Python9Code/com/twowater/mtest1.py
0 → 100644
浏览文件 @
278330d5
#!/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
))
Code/Python9Code/com/twowater/mtest2.py
0 → 100644
浏览文件 @
278330d5
#!/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
Code/Python9Code/com/twowater/mtest3.py
0 → 100644
浏览文件 @
278330d5
#!/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
)
Code/Python9Code/com/twowater/mtest4.py
0 → 100644
浏览文件 @
278330d5
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
class
User
(
object
):
def
upgrade
(
self
):
pass
def
_buy_equipment
(
self
):
pass
def
__pk
(
self
):
pass
Code/Python9Code/com/twowater/mtest5.py
0 → 100644
浏览文件 @
278330d5
#!/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
)
Code/Python9Code/com/twowater/mtest6.py
0 → 100644
浏览文件 @
278330d5
#!/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
())
Code/Python9Code/com/twowater/mtest7.py
0 → 100644
浏览文件 @
278330d5
#!/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
())
Code/Python9Code/com/twowater/mtest8.py
0 → 100644
浏览文件 @
278330d5
#!/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
))
Code/Python9Code/com/twowater/mtest9.py
0 → 100644
浏览文件 @
278330d5
#!/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
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录