From 758d04b1fd55efd5ee480080642b72a353c6ffcd Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Fri, 9 Mar 2018 12:16:27 +0800 Subject: [PATCH 01/37] Fix link GithubTutorial.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b7da0d..b326a2c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 这个文件了定义了换行格式字符编码。一般的代码编辑器都可以识别 -[GitHub用法](./blob/master/01/GithubTutorial.md) +[GitHub用法](./01/GithubTutorial.md) ##### 关于比较常见的python 代码头部 ```python From b546955255b3c29a507135d2b6f850c8cb3088c7 Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Fri, 9 Mar 2018 20:45:03 +0800 Subject: [PATCH 02/37] Fix GithubTutorial --- 01/GithubTutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01/GithubTutorial.md b/01/GithubTutorial.md index 83343cb..5718d09 100644 --- a/01/GithubTutorial.md +++ b/01/GithubTutorial.md @@ -14,7 +14,7 @@ - Mac: 默认安装了Git - Linux: - 对于大多数发行版,通过软件包获取即可~(目测不需要展开)~ + 对于大多数发行版,通过软件包获取即可~~(目测不需要展开)~~ - debian && Ubuntu && LinuxMint && deepin ```sh apt install git @@ -38,7 +38,7 @@ 最后不管你是什么系统,都要注册GitHub账号哦,注册方式很简单这里略过,温馨提示一点,请认真填写您的用户名和邮箱地址,他们真的很有用! -***用户名很重要。请不要乱取!!!***。这里很重要!!!。用户名以后可以更改。所以不用太在意 +**用户名很重要。请不要乱取!!!**。这里很重要!!!。用户名以后可以更改。所以不用太在意 github的用户名会作为url的一部分,所以对大小写不敏感。如:http://github.com/:你的用户名/:你的仓库名 From d863a4b9b9abc581aa05e56311426eee741cf798 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Fri, 9 Mar 2018 21:03:52 +0800 Subject: [PATCH 03/37] with GitHubTutorial.py fixed --- 01/GithubTutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01/GithubTutorial.md b/01/GithubTutorial.md index 5718d09..d0ab6f9 100644 --- a/01/GithubTutorial.md +++ b/01/GithubTutorial.md @@ -38,7 +38,7 @@ 最后不管你是什么系统,都要注册GitHub账号哦,注册方式很简单这里略过,温馨提示一点,请认真填写您的用户名和邮箱地址,他们真的很有用! -**用户名很重要。请不要乱取!!!**。这里很重要!!!。用户名以后可以更改。所以不用太在意 +**用户名很重要。请不要乱取!!!**。这里请千万注意!!!。(虽然用户名和邮箱一样是可以后期修改的,只不过并不建议。) github的用户名会作为url的一部分,所以对大小写不敏感。如:http://github.com/:你的用户名/:你的仓库名 From bfd6b4cbd6133b044b22166138c4c129dc72f949 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 00:14:41 +0800 Subject: [PATCH 04/37] add type_dictionary.py --- .idea/JRT-PythonTutorial.iml | 12 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 271 +++++++++++++++++++++++++++++++++++ 01/12-type_dictionary.py | 104 ++++++++++++++ 6 files changed, 405 insertions(+) create mode 100644 .idea/JRT-PythonTutorial.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 01/12-type_dictionary.py diff --git a/.idea/JRT-PythonTutorial.iml b/.idea/JRT-PythonTutorial.iml new file mode 100644 index 0000000..6f63a63 --- /dev/null +++ b/.idea/JRT-PythonTutorial.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3130edc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8dda984 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..3b7cd3a --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1520601251824 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/01/12-type_dictionary.py b/01/12-type_dictionary.py new file mode 100644 index 0000000..a0e61f2 --- /dev/null +++ b/01/12-type_dictionary.py @@ -0,0 +1,104 @@ +# 轮到字典了 +# 吐槽一下:第一部分终于结束了,不知道现在还剩几个人在听啊 +# 有了前面序列的基础,字典其实也就不难理解了,毕竟操作上有很多相似之处,只不过字典是一种映射 +# 看看用以前的方法弄一个电话簿 +from copy import deepcopy +names = ['mdzz0', 'mdzz1', 'mdzz2'] +phones = ['01275', '02336', '03997'] +for name in names: + print(name+':'+phones[names.index(name)]) + +# 再看看字典版本 +phone_dict = dict(zip(names, phones)) +# print(type(phone_dict)) +print(phone_dict) +# 上面的例子看出来,字典是更加接近于人类思维的数据类型,此外也展示了dict的功能 +# dict()是一个类型函数,可以从映射来创建字典 +print(dict([('mdzz0', '01'), ('mdzz1', '02')])) +print(dict(mdzz0='01', mdzz1='02')) # 键不要加引号 + +# 一些字典操作 +print(len(phone_dict)) +print('mdzz1:'+phone_dict['mdzz1']) # 字典索引方法 +phone_dict['mdzz1'] = '01111' +print('mdzz1:'+phone_dict['mdzz1']) +print('mdzz1' in phone_dict) # 检查字典中是否有该键 +phone_dict['mdzz3'] = '00000' # 字典可以动态添加项,而序列不可能那一个不存在的索引去访问 +print(phone_dict) + +# 依赖于字典的字符串格式化,之前说过了使用元组传入数据的字符串格式化 +print("**********************************formatted string*********************************") +str_origin = "mdzz0:%(mdzz0)s\nmdzz1:%(mdzz1)s\nmdzz2:%(mdzz2)s" +str_formate =str_origin % phone_dict +print(str_formate) + +template = '''\ + +%(title)s + +

%(title)s

+

%(text)s

+ + +''' +data = template % {'title':'My Page', 'text':'Welcome to my home page!'} +print(data) + +print('************************************字典方法*************************************') +dict_test = {'a': '1'} +dict_test1 = dict_test # 目前二者关联到同一个字典对象 +print("dict_test:", dict_test) +print('dict_test1: ', dict_test1) +dict_test = {} # 给dict_test关联到一个新字典,这时候两者就不再一样了 +print('dict_test: ', dict_test) +print('dict_test1: ', dict_test1) +dict_test = {'a': '1'} +dict_test1 = dict_test # 目前二者关联到同一个字典对象 +dict_test.clear() # 这样会清除掉原始字典,两个对象都变为空 +print('dict_test: ', dict_test) +print('dict_test1: ', dict_test1) + +# 浅拷贝,理解难度变大了哦 +d = {'name': ['jrt', 'JRT']} # 字典某个键对应的值又是一个新的容器,这样对于浅拷贝来说就是简单复制对象的值 +c = d.copy() +d['name'].append('copy') +print('origin', d['name']) +print('copy:', c['name']) + +d = {'name': ['jrt', 'JRT']} + +dc = deepcopy(d) +d['name'].append('deepcopy') # 对于深拷贝,当对象的值是引用时,会递归的复制,得到的拷贝和原始对象完全一致且独立 +print('origin', d['name']) +print('deepcopy', dc['name']) +print(phone_dict.keys()) +print(phone_dict.items()) +print(phone_dict.values()) + +a = phone_dict.pop('mdzz0') +print('弹出的值:'+a) +print('弹出项后字典:', phone_dict) + + +phone_dict.popitem() +print('随机弹出一项后:', phone_dict) +phone_dict.popitem() +print('随机弹出一项后:', phone_dict) +phone_dict.popitem() +print('随机弹出一项后:', phone_dict) + +# the end +# 是不是看到了希望呢? + + + + + + + + + + + + + From 4924c76d81d85727469e399a85ba660ff97462fe Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 00:16:23 +0800 Subject: [PATCH 05/37] remove .idea --- .idea/JRT-PythonTutorial.iml | 12 -- .idea/misc.xml | 4 - .idea/modules.xml | 8 -- .idea/vcs.xml | 6 - .idea/workspace.xml | 271 ----------------------------------- 5 files changed, 301 deletions(-) delete mode 100644 .idea/JRT-PythonTutorial.iml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/JRT-PythonTutorial.iml b/.idea/JRT-PythonTutorial.iml deleted file mode 100644 index 6f63a63..0000000 --- a/.idea/JRT-PythonTutorial.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 3130edc..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 8dda984..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 3b7cd3a..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1520601251824 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 2d77fc4cabfbebe72ef4058500f3dac85fc2017e Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 00:18:24 +0800 Subject: [PATCH 06/37] fixed the file's name --- 01/{12-type_dictionary.py => 14-type_dictionary.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 01/{12-type_dictionary.py => 14-type_dictionary.py} (100%) diff --git a/01/12-type_dictionary.py b/01/14-type_dictionary.py similarity index 100% rename from 01/12-type_dictionary.py rename to 01/14-type_dictionary.py From 86b6a65dcfaa21a6f979f1c44487256c5d8f80c6 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 00:14:41 +0800 Subject: [PATCH 07/37] add type_dictionary.py --- 01/14-type_dictionary.py | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 01/14-type_dictionary.py diff --git a/01/14-type_dictionary.py b/01/14-type_dictionary.py new file mode 100644 index 0000000..a0e61f2 --- /dev/null +++ b/01/14-type_dictionary.py @@ -0,0 +1,104 @@ +# 轮到字典了 +# 吐槽一下:第一部分终于结束了,不知道现在还剩几个人在听啊 +# 有了前面序列的基础,字典其实也就不难理解了,毕竟操作上有很多相似之处,只不过字典是一种映射 +# 看看用以前的方法弄一个电话簿 +from copy import deepcopy +names = ['mdzz0', 'mdzz1', 'mdzz2'] +phones = ['01275', '02336', '03997'] +for name in names: + print(name+':'+phones[names.index(name)]) + +# 再看看字典版本 +phone_dict = dict(zip(names, phones)) +# print(type(phone_dict)) +print(phone_dict) +# 上面的例子看出来,字典是更加接近于人类思维的数据类型,此外也展示了dict的功能 +# dict()是一个类型函数,可以从映射来创建字典 +print(dict([('mdzz0', '01'), ('mdzz1', '02')])) +print(dict(mdzz0='01', mdzz1='02')) # 键不要加引号 + +# 一些字典操作 +print(len(phone_dict)) +print('mdzz1:'+phone_dict['mdzz1']) # 字典索引方法 +phone_dict['mdzz1'] = '01111' +print('mdzz1:'+phone_dict['mdzz1']) +print('mdzz1' in phone_dict) # 检查字典中是否有该键 +phone_dict['mdzz3'] = '00000' # 字典可以动态添加项,而序列不可能那一个不存在的索引去访问 +print(phone_dict) + +# 依赖于字典的字符串格式化,之前说过了使用元组传入数据的字符串格式化 +print("**********************************formatted string*********************************") +str_origin = "mdzz0:%(mdzz0)s\nmdzz1:%(mdzz1)s\nmdzz2:%(mdzz2)s" +str_formate =str_origin % phone_dict +print(str_formate) + +template = '''\ + +%(title)s + +

%(title)s

+

%(text)s

+ + +''' +data = template % {'title':'My Page', 'text':'Welcome to my home page!'} +print(data) + +print('************************************字典方法*************************************') +dict_test = {'a': '1'} +dict_test1 = dict_test # 目前二者关联到同一个字典对象 +print("dict_test:", dict_test) +print('dict_test1: ', dict_test1) +dict_test = {} # 给dict_test关联到一个新字典,这时候两者就不再一样了 +print('dict_test: ', dict_test) +print('dict_test1: ', dict_test1) +dict_test = {'a': '1'} +dict_test1 = dict_test # 目前二者关联到同一个字典对象 +dict_test.clear() # 这样会清除掉原始字典,两个对象都变为空 +print('dict_test: ', dict_test) +print('dict_test1: ', dict_test1) + +# 浅拷贝,理解难度变大了哦 +d = {'name': ['jrt', 'JRT']} # 字典某个键对应的值又是一个新的容器,这样对于浅拷贝来说就是简单复制对象的值 +c = d.copy() +d['name'].append('copy') +print('origin', d['name']) +print('copy:', c['name']) + +d = {'name': ['jrt', 'JRT']} + +dc = deepcopy(d) +d['name'].append('deepcopy') # 对于深拷贝,当对象的值是引用时,会递归的复制,得到的拷贝和原始对象完全一致且独立 +print('origin', d['name']) +print('deepcopy', dc['name']) +print(phone_dict.keys()) +print(phone_dict.items()) +print(phone_dict.values()) + +a = phone_dict.pop('mdzz0') +print('弹出的值:'+a) +print('弹出项后字典:', phone_dict) + + +phone_dict.popitem() +print('随机弹出一项后:', phone_dict) +phone_dict.popitem() +print('随机弹出一项后:', phone_dict) +phone_dict.popitem() +print('随机弹出一项后:', phone_dict) + +# the end +# 是不是看到了希望呢? + + + + + + + + + + + + + From 210ed2982f17e55cfcde47b85d0a35be2632c136 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 19:30:13 +0800 Subject: [PATCH 08/37] nothing --- .idea/JRT-PythonTutorial.iml | 12 + .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 430 +++++++++++++++++++++++++++++++++++ 01/14-type_dictionary.py | 5 + 6 files changed, 465 insertions(+) create mode 100644 .idea/JRT-PythonTutorial.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/JRT-PythonTutorial.iml b/.idea/JRT-PythonTutorial.iml new file mode 100644 index 0000000..6f63a63 --- /dev/null +++ b/.idea/JRT-PythonTutorial.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3130edc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8dda984 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..525f9c3 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,430 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1520659761592 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/01/14-type_dictionary.py b/01/14-type_dictionary.py index a0e61f2..81b7efb 100644 --- a/01/14-type_dictionary.py +++ b/01/14-type_dictionary.py @@ -91,6 +91,11 @@ # 是不是看到了希望呢? +strings = ['string0', 'string1', 'string2', 'string3'] +for string in strings: + print(string) + + From 34ff01bfb320276cc9139e2f680f029c5297ffa0 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 21:59:42 +0800 Subject: [PATCH 09/37] =?UTF-8?q?=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/JRT-PythonTutorial.iml | 12 +++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 173 +++++++++++++++++++++++++++++++++++ 01/14-type_dictionary.py | 12 --- 6 files changed, 203 insertions(+), 12 deletions(-) create mode 100644 .idea/JRT-PythonTutorial.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/JRT-PythonTutorial.iml b/.idea/JRT-PythonTutorial.iml new file mode 100644 index 0000000..6f63a63 --- /dev/null +++ b/.idea/JRT-PythonTutorial.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3130edc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8dda984 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..b825012 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1520690236214 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/01/14-type_dictionary.py b/01/14-type_dictionary.py index 4360f77..1741c62 100644 --- a/01/14-type_dictionary.py +++ b/01/14-type_dictionary.py @@ -91,18 +91,6 @@ # 是不是看到了希望呢? -<<<<<<< HEAD -strings = ['string0', 'string1', 'string2', 'string3'] -for string in strings: - print(string) - - -======= ->>>>>>> 86b6a65dcfaa21a6f979f1c44487256c5d8f80c6 - - - - From 0f213e368b68b2ab8d65d99c00f81a4391095572 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 10 Mar 2018 23:17:00 +0800 Subject: [PATCH 10/37] calculator(no condition).py --- .idea/workspace.xml | 145 +++++++++++++++++++++++++++-- 01/14-type_dictionary.py | 2 +- test/calculator-1(no condition).py | 2 + 3 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 test/calculator-1(no condition).py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b825012..0bd242b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -17,11 +17,21 @@ - + - - + + + + + + + + + + + + @@ -36,12 +46,13 @@ - @@ -73,6 +84,20 @@ - @@ -71,7 +133,6 @@ - @@ -94,31 +155,23 @@ - - - - - - + + - + + + - + + - - + + + @@ -248,25 +321,26 @@ - + + - + - - - - - + + + + - + - - + + - + + @@ -280,16 +354,75 @@ - - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_init.py" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_init.py" new file mode 100644 index 0000000..bdb158b --- /dev/null +++ "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_init.py" @@ -0,0 +1,5 @@ +# 初始化数据库 +def data_init(data): + data['first_name'] = {} + data['last_name'] = {} + diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_sort.py" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_sort.py" new file mode 100644 index 0000000..9116aa9 --- /dev/null +++ "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_sort.py" @@ -0,0 +1,9 @@ +def data_sort(data, label, name): + """ + :param data: 数据库名称 + :param label: 查找方式,姓还是名 + :param full_name: 对应于查找方式,输入要查找的名字中的字段 + :return: nothing + + """ + return data[label].get(name) # dict.get(key),返回对应的value diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_store.py" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_store.py" new file mode 100644 index 0000000..c762ce6 --- /dev/null +++ "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/data_store.py" @@ -0,0 +1,18 @@ +# 数据存储 +# 包导入的路径问题很坑啊 +# pycharm把根目录当成项目所在路径 +from data_sort import data_sort + + +def data_store(data, full_name): + labels = ['first_name', 'last_name'] + names = full_name.split() + # 注意存储名字到数据库的时候,要在姓和名的两个键下面都存储好相应的全名 + for label, name in zip(labels, names): + result = data_sort(data, label, name) # 获取全名列表 + if result: + result.append(full_name) + else: + data[label][name] = [full_name] + + pass diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/main.py" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/main.py" new file mode 100644 index 0000000..7aaae44 --- /dev/null +++ "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/main.py" @@ -0,0 +1,16 @@ +from data_init import data_init +from data_store import data_store +from data_sort import data_sort +data = {} +data_init(data) +# print(data) +data_store(data, "关键字 参数") +data_store(data, "J RT") +data_store(data, "J AA") +data_store(data, "B RT") +full_name = input("输入全名,注意空格分隔开姓和名\n") +data_store(data, full_name) +label = input("输入要first_name 或者 last_name来指定查找的字段\n") +name = input("输入要查找字段:%s的值?\n" % label) +result = data_sort(data, label, name) +print(result) diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/readme.md" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/readme.md" new file mode 100644 index 0000000..4fd4a29 --- /dev/null +++ "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/readme.md" @@ -0,0 +1 @@ +# 这是一个稍微复杂的项目 From 8c318e3a31ef01a0a2173488cebde3878c1c0f15 Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Mon, 12 Mar 2018 09:40:11 +0800 Subject: [PATCH 18/37] Remove .idea/workspace.xml --- .idea/workspace.xml | 431 -------------------------------------------- 1 file changed, 431 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 59c7184..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1520690236214 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 3ad16ce1c05d25c3772ec471807377f48dfb8418 Mon Sep 17 00:00:00 2001 From: UBWprayer <736002058@qq.com> Date: Mon, 12 Mar 2018 17:56:59 +0800 Subject: [PATCH 19/37] my calculator --- test/calculator2.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/calculator2.py diff --git a/test/calculator2.py b/test/calculator2.py new file mode 100644 index 0000000..21a135f --- /dev/null +++ b/test/calculator2.py @@ -0,0 +1,17 @@ +a = float(input("Please input the first number:\n>")) +b = input("Please input operator:\n>") +if b == '^': + c = int(input("Please input a integer:\n>")) + print("The result is:", a ** c) +else: + c = float(input("Please input the second number:\n>")) + if b == '+': + print("The result is:", a + c) + elif b == '-': + print("The result is:", a - c) + elif b == '*': + print("The result is:", a * c) + elif b == '/': + print("The result is:", a / c) + else: + print("Please input +,-,*,/or^as an operator") From 296aaaefc0f1283f735bdb4c54073aff363d618f Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Mon, 12 Mar 2018 22:04:57 +0800 Subject: [PATCH 20/37] add 02/condition --- .gitignore | 2 +- 02/condition.py | 120 ++++++++ .../.idea/workspace.xml" | 266 ++++++++++++++++++ 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 02/condition.py create mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" diff --git a/.gitignore b/.gitignore index 485dee6..85e7c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -.idea +/.idea/ diff --git a/02/condition.py b/02/condition.py new file mode 100644 index 0000000..9d8fd1d --- /dev/null +++ b/02/condition.py @@ -0,0 +1,120 @@ +from math import sqrt +# 现在开始来看看程序的流程控制,有了这些之后理论上就什么都可以做了,突出服务于使用的目的,这里真的很简单 +# 先来看一看语法糖 +# 序列解包1 +dictionary = {'a': 1, 'b': 2, 'c': 3} +for key, value in dictionary.items(): # 这里就是一种unpacking + print(key, value) +values = 1, 2, 3 +# 序列解包1 +x, y, z = values +print(x, y, z) +# 序列解包2 +x, y, z = 1, 2, 3 +print(x, y, z) +# 序列解包3 +x, y = y, x +print(x, y, z) +# 链式赋值 +x = y = 1 +print(x, y) +# 增量赋值 +x += 1 +y **= 2 +z /= 2 +print(x, y, z) + +# 分支结构 +num = float(input("please input a number between 0~100\n>")) +assert(0 < num < 100) # 使用断言 +if num > 90: + print("congratulations!") +elif num > 60: + print("emmmmm") +else: + print("sorry!") + +name = input('whats your name?\n>') +if name.endswith('jrt'): + if name.startswith('Mr.'): + print('hello Mr. jrt') + if name.startswith('Mrs.'): + print('hello Mrs. jrt') + else: + print('hello jrt') +else: + print("hello") + + +# 来算算数吧,输出10!,下面这两种循环都可以 +i = 1 +res = 1 +while(i <= 10): + res *= i + i += 1 +print(res) + +res = 1 +for i in range(1, 11): # xrange()函数是更高效的,他返回的是一个可迭代对象,而range()返回的直接就是一个列表 + res *= i +print(res) + +words = ['life', 'is', 'short', 'I', 'use', 'python'] +for word in words: + print(word) + +d = {'x': 1, 'y': 2, 'z': 3} +for key in d: + print(key + ':', d[key]) + +# 并行迭代的实现,很常见的用法 +names = ['a', 'b', 'c'] +scores = [90, 80, 70] +for name, score in zip(names, scores): + print(name, ':', score) + +print('********************************************************************') +strings = ['asfsfsf', 'bldfjgld', 'slfgsdfhgsidf', 'oertuwoehnccxvnm'] +for string in strings: + if 'fj' in string: + print(string) + index = strings.index(string) + strings[index] = '' + +strings = ['asfsfsf', 'bldfjgld', 'slfgsdfhgsidf', 'oertuwoehnccxvnm'] +index = 0 +for string in strings: + if 'sid' in string: + print(string) + strings[index] = '' +index += 1 + + +strings = ['asfsfsf', 'bldfjgld', 'slfgsdfhgsidf', 'oertuwoehnccxvnm'] +# dict是具有(key,value)的 而类似的enumerate()函数可以返回序列的(index,value) +for index, string in enumerate(strings): + if 'nm' in string: + print(string) + strings[index] = '' + + + + +for n in range(99,81,-1): + res = sqrt(n) + if res == int(res): # 判断是否是整数 + print(n) + break +else: + print("nothing find") + +# 列表推导式,小小的重点一下 +print([x**2 for x in range(0, 100)]) +print([x for x in range(0, 100) if x % 2 == 0]) +# 下面这句话注意一点,这个可不是并行迭代,而是实现了多重循环的效果,找找笛卡尔积的感觉 +print([x+y for x in range(0, 100) for y in range(100, 0, -1)]) + + +# ok, that's all + + diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" new file mode 100644 index 0000000..0374e36 --- /dev/null +++ "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" @@ -0,0 +1,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1520782199944 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ea368dbaee1f6789887a8f35c33feddad0a86ebf Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Tue, 13 Mar 2018 09:57:38 +0800 Subject: [PATCH 21/37] test webhook and robot --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b326a2c..6170252 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # JRT-PythonTutorial **_用于JRT学习交流_** + ## 简要说明 - 目录序号由一个 ~~两位十进制~~ (用0补不是markdown语法) 数字组成,内容逐渐更新,每一个目录表示一天的内容,整个项目包含基础语法和附加项目两部分,附加项目部分欢迎大家共同贡献代码,每个小项目单独放入一个文件夹,放在Tutorial根目录即可。 From 37e15eecdebe333cfbc879503cc939731ae0e6bd Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Tue, 13 Mar 2018 10:06:02 +0800 Subject: [PATCH 22/37] test webhook and robot2 --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6170252..b326a2c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # JRT-PythonTutorial **_用于JRT学习交流_** - ## 简要说明 - 目录序号由一个 ~~两位十进制~~ (用0补不是markdown语法) 数字组成,内容逐渐更新,每一个目录表示一天的内容,整个项目包含基础语法和附加项目两部分,附加项目部分欢迎大家共同贡献代码,每个小项目单独放入一个文件夹,放在Tutorial根目录即可。 From ba1a5f4711eebd470986849d8ca20c4e20b6c8e0 Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Tue, 13 Mar 2018 21:17:46 +0800 Subject: [PATCH 23/37] Add Git-Tutorial --- 01/Git-Tutorial.md | 14 ++++++++++++++ README.md | 1 + 2 files changed, 15 insertions(+) create mode 100644 01/Git-Tutorial.md diff --git a/01/Git-Tutorial.md b/01/Git-Tutorial.md new file mode 100644 index 0000000..ab6caa4 --- /dev/null +++ b/01/Git-Tutorial.md @@ -0,0 +1,14 @@ +Git使用 +===== + +为什么要把Git 和 Github 分开呢。应为本身就是两个东西。 + +Git 是版本控制软件。类似的还有svn + +Github 是代码托管平台。类似的有gitlib, gitee, bitbucket, Coding........ + +> 为什么要用Github? Github 重新定义是社会化编程这一概念 + +这里不想说千篇一律的东西。比如分支管理,打标签啊之类的 + +[如何写一个优秀的commit](https://github.com/linuxdeepin/developer-center/wiki/Git-Commit-Message-Style) diff --git a/README.md b/README.md index b326a2c..ab5cb86 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ 这个文件了定义了换行格式字符编码。一般的代码编辑器都可以识别 +[Git用法](./01/Git-Tutorial.md) [GitHub用法](./01/GithubTutorial.md) ##### 关于比较常见的python 代码头部 From 06f3fba9bef245c90c86bde3c3f74e31008111a5 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Thu, 15 Mar 2018 20:49:37 +0800 Subject: [PATCH 24/37] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +- .../.idea/workspace.xml" | 266 ------------------ ...ap\347\232\204\347\224\250\346\263\225.py" | 0 3 files changed, 4 insertions(+), 270 deletions(-) delete mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" rename "test/map\347\232\204\351\252\232\347\224\250\346\263\225.py" => "test/map\347\232\204\347\224\250\346\263\225.py" (100%) diff --git a/README.md b/README.md index b326a2c..976eca0 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ or *** ## 目录 -1. :常量,变量,运算符,类型,内置函数 -2. :流程控制,表达式,语句,模块,导入 -3. :函数,面向对象 -4. 欢迎贡献 +1. 常量,变量,运算符,内置函数,数据类型 +2. 流程控制,导入 +3. 函数和面向对象基础 +4. 模块和高级专题 diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" deleted file mode 100644 index 0374e36..0000000 --- "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/.idea/workspace.xml" +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1520782199944 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git "a/test/map\347\232\204\351\252\232\347\224\250\346\263\225.py" "b/test/map\347\232\204\347\224\250\346\263\225.py" similarity index 100% rename from "test/map\347\232\204\351\252\232\347\224\250\346\263\225.py" rename to "test/map\347\232\204\347\224\250\346\263\225.py" From 423d78eb12577ef91332ce07cd846ab6dd80aeb2 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Thu, 15 Mar 2018 22:12:35 +0800 Subject: [PATCH 25/37] add personal directory --- test/{ => UBWprayer}/calculator2.py | 0 .../caculator1 - \345\211\257\346\234\254.py" | 38 +++++++++--------- test/{ => guono912}/caculator.py | 40 +++++++++---------- 3 files changed, 39 insertions(+), 39 deletions(-) rename test/{ => UBWprayer}/calculator2.py (100%) rename "test/caculator1 - \345\211\257\346\234\254.py" => "test/caoshaun/caculator1 - \345\211\257\346\234\254.py" (95%) rename test/{ => guono912}/caculator.py (94%) diff --git a/test/calculator2.py b/test/UBWprayer/calculator2.py similarity index 100% rename from test/calculator2.py rename to test/UBWprayer/calculator2.py diff --git "a/test/caculator1 - \345\211\257\346\234\254.py" "b/test/caoshaun/caculator1 - \345\211\257\346\234\254.py" similarity index 95% rename from "test/caculator1 - \345\211\257\346\234\254.py" rename to "test/caoshaun/caculator1 - \345\211\257\346\234\254.py" index 9df437a..462a440 100644 --- "a/test/caculator1 - \345\211\257\346\234\254.py" +++ "b/test/caoshaun/caculator1 - \345\211\257\346\234\254.py" @@ -1,19 +1,19 @@ -x = float(input('请输入第一个数字')) -form = input('请输入运算符') -y = float(input('请输入第二个数字')) -if form == '+': - ans = x + y -elif form == '-': - ans = x - y -elif form == '*': - ans = x * y -elif form == '/': - if y == 0: - print('无法计算') - input() - exit() - else: - ans = x/y -elif form == '^' or '**': - ans = x ** y -print('答案为',ans) +x = float(input('请输入第一个数字')) +form = input('请输入运算符') +y = float(input('请输入第二个数字')) +if form == '+': + ans = x + y +elif form == '-': + ans = x - y +elif form == '*': + ans = x * y +elif form == '/': + if y == 0: + print('无法计算') + input() + exit() + else: + ans = x/y +elif form == '^' or '**': + ans = x ** y +print('答案为',ans) diff --git a/test/caculator.py b/test/guono912/caculator.py similarity index 94% rename from test/caculator.py rename to test/guono912/caculator.py index f70ac88..79c9239 100644 --- a/test/caculator.py +++ b/test/guono912/caculator.py @@ -1,20 +1,20 @@ -print("输入算式,不同元素用空格隔开\n") -x,form,y=input().split() -x=float(x) -y=float(y) -if form is '+': - res=x+y -if form is '-': - res=x-y -if form is '*': - res=x*y -if form is '^': - res=x**y -if form is '/': - if y!=0: - res=x/y - else: - print("除数不能为零") - exit() -print(x,form,y,"=",res) -input() +print("输入算式,不同元素用空格隔开\n") +x,form,y=input().split() +x=float(x) +y=float(y) +if form is '+': + res=x+y +if form is '-': + res=x-y +if form is '*': + res=x*y +if form is '^': + res=x**y +if form is '/': + if y!=0: + res=x/y + else: + print("除数不能为零") + exit() +print(x,form,y,"=",res) +input() From 7bd00482993e575ffda63794015592e6f6f37e18 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Thu, 15 Mar 2018 23:54:05 +0800 Subject: [PATCH 26/37] something about tkinter --- 04/tkinter/01.py | 22 ++++++++++++++++++++++ 04/tkinter/02.py | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 04/tkinter/01.py create mode 100644 04/tkinter/02.py diff --git a/04/tkinter/01.py b/04/tkinter/01.py new file mode 100644 index 0000000..e73d78d --- /dev/null +++ b/04/tkinter/01.py @@ -0,0 +1,22 @@ +import tkinter as tk +status = False +window = tk.Tk("my first window") +window.geometry('200x150') +var = tk.StringVar() +lb = tk.Label(window, textvariable=var, bg='red', font=('Arial', 12), width=15, height=2) +lb.pack() + + +def on_click(): + global status + if not status: + status = True + var.set("I am clicked") + else: + status = False + var.set("") + +bt = tk.Button(window, text='click me', width=15, height=2, command=on_click) +bt.pack() +window.mainloop() # 进入主循环 + diff --git a/04/tkinter/02.py b/04/tkinter/02.py new file mode 100644 index 0000000..6c17251 --- /dev/null +++ b/04/tkinter/02.py @@ -0,0 +1,23 @@ +# 想法来自网络 +import tkinter as tk +window = tk.Tk('My Window') +window.geometry('700x500') +entry = tk.Entry(show=None, width=30) # 可以通过show=''来指定掩码 +entry.pack() + + +def add2point(): + t.insert('insert', entry.get()) # insert模式用于在光标处插入 + + +def add2end(): + t.insert('end', entry.get()) # end模式用于在尾部插入, 可以通过m.n模式来指定插入的行和列 + +bt1 = tk.Button(window, text='add to the point', bg='blue', width=15, height=2, command=add2point) +bt1.pack() +bt2 = tk.Button(window, text='add to the end', bg='green', width=15, height=2, command=add2end) +bt2.pack() +t = tk.Text(window, width=30, height=10) +t.pack() +window.mainloop() + From c861e6455f46de1d9a36acedcc0e63f2ae50ba05 Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Fri, 16 Mar 2018 19:38:44 +0800 Subject: [PATCH 27/37] update tkinter --- 04/tkinter/02.py | 2 +- 04/tkinter/03.py | 31 +++++++++++++++++++++++++++++++ 04/tkinter/04.py | 19 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 04/tkinter/03.py create mode 100644 04/tkinter/04.py diff --git a/04/tkinter/02.py b/04/tkinter/02.py index 6c17251..c71490e 100644 --- a/04/tkinter/02.py +++ b/04/tkinter/02.py @@ -2,7 +2,7 @@ import tkinter as tk window = tk.Tk('My Window') window.geometry('700x500') -entry = tk.Entry(show=None, width=30) # 可以通过show=''来指定掩码 +entry = tk.Entry(window, show=None, width=30) # 可以通过show=''来指定掩码 entry.pack() diff --git a/04/tkinter/03.py b/04/tkinter/03.py new file mode 100644 index 0000000..15119eb --- /dev/null +++ b/04/tkinter/03.py @@ -0,0 +1,31 @@ +import tkinter as tk +window = tk.Tk("My Window") +window.geometry('200x300') +var1 = tk.StringVar() +label = tk.Label(window, textvariable=var1, bg='red', width=30, height=2) +label.pack() +# print(type(var1)) + + +# 下面是按钮的回调函数 +def print2label(): + global var1 # 使用全局作用域的变量 + res = lb.get(lb.curselection()) # 获取光标指向的item + var1.set(res) +button = tk.Button(window, text='print to the label', command=print2label, width=30, height=2) +button.pack() +var2 = tk.StringVar() # var2是放在列表框当中的 +var2.set((1, 2, 3, 4)) # 元组参数 + + +lb = tk.Listbox(window, listvariable=var2) +lb.pack() +tuple_test = ['J', 'R', 'T'] +for item in tuple_test: + lb.insert('end', item) +lb.insert(1, 'JRT') +lb.insert(2, 'abc') +lb.delete(2) +window.mainloop() + + diff --git a/04/tkinter/04.py b/04/tkinter/04.py new file mode 100644 index 0000000..9eed928 --- /dev/null +++ b/04/tkinter/04.py @@ -0,0 +1,19 @@ +import tkinter as tk +window = tk.Tk("My window") +window.geometry('500x400') +lb = tk.Label(window, width=30, height=2, bg='green') +lb.pack() +var = tk.StringVar() + + +def print2label(): + lb.config(text="%s was selevted" % var.get()) # 重新配置lb的属性 + +rb1 = tk.Radiobutton(window, command=print2label, variable=var, value='button1', text='button1') +rb1.pack() +rb2 = tk.Radiobutton(window, command=print2label, variable=var, value='button2', text='button1') +rb2.pack() +rb3 = tk.Radiobutton(window, command=print2label, variable=var, value='button3', text='button1') +rb3.pack() +window.mainloop() + From 436d6d38583072e44029255d69fa39a9376408f4 Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Fri, 16 Mar 2018 21:10:17 +0800 Subject: [PATCH 28/37] Update Git-Tutorial --- 01/Git-Tutorial.md | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 44 insertions(+) diff --git a/01/Git-Tutorial.md b/01/Git-Tutorial.md index ab6caa4..2ab411e 100644 --- a/01/Git-Tutorial.md +++ b/01/Git-Tutorial.md @@ -11,4 +11,47 @@ Github 是代码托管平台。类似的有gitlib, gitee, bitbucket, Coding..... 这里不想说千篇一律的东西。比如分支管理,打标签啊之类的 + +[git中文文档](https://git-scm.com/book/zh/v2) + +[如果你看不懂版本分支图,请看这篇](https://github.com/SB-IM/developer-center/wiki/Guidelines-for-Developers) + [如何写一个优秀的commit](https://github.com/linuxdeepin/developer-center/wiki/Git-Commit-Message-Style) + + +### git 常用命令(请根据此表单看文档,按使用频率排序) + +> 这里是天天用git的人总结的 + +- 查看系列(不对仓库造成任何变化的) + - git status + - git diff + - git log + - git branch +- 日常用 + - git commit -am "我是描述" + - git pull + - git push + - git checkout 分支名 + - git add . +- 版本控制用 + - git merge + - git checkout -b 分支名 + - git reset --hard 版本哈希值 + - git rebase -i 版本哈希值 +- 发布版本用 + - git tag -am "我是描述" + +### 关于git 配置 + +> 分成两部分,一部分是git 的用户全局配置,一部分是git 仓库配置。(注:我没听说过git 有系统全局配置,做git 服务器会有) + +#### git 的用户全局配置 +一般都在这个里`~/.gitconfig`,用`git config --global user.name "John Doe"` 的配置会存在这里 + +#### git 仓库配置 +这个在每个git 仓库里都有,在`.git/config`,这里记录着远程仓库的名称和地址。(注:`origin` 是仓库的默认值。不指定仓库名会使用`origin`仓库) + +#### .gitignore +用于不想被控制版本的文件,比如编译后的产物,中间的tmp。。。但要注意已经加入版本控制的文件不受这个文件影响。(可以理解这个是git add 时会发生作用的) + diff --git a/README.md b/README.md index 385c06f..7112ae5 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ [Git用法](./01/Git-Tutorial.md) + [GitHub用法](./01/GithubTutorial.md) ##### 关于比较常见的python 代码头部 From bacd37181827c2f75760ef97122d1e0bc0a0dc8b Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 17 Mar 2018 12:46:04 +0800 Subject: [PATCH 29/37] decorator --- 04/decorator/01.py | 11 +++++++++++ 04/decorator/02.py | 14 ++++++++++++++ 04/decorator/03.py | 24 ++++++++++++++++++++++++ 04/decorator/04.py | 24 ++++++++++++++++++++++++ 04/decorator/05.py | 23 +++++++++++++++++++++++ 04/tkinter/05.py | 7 +++++++ 6 files changed, 103 insertions(+) create mode 100644 04/decorator/01.py create mode 100644 04/decorator/02.py create mode 100644 04/decorator/03.py create mode 100644 04/decorator/04.py create mode 100644 04/decorator/05.py create mode 100644 04/tkinter/05.py diff --git a/04/decorator/01.py b/04/decorator/01.py new file mode 100644 index 0000000..b9873b9 --- /dev/null +++ b/04/decorator/01.py @@ -0,0 +1,11 @@ +# 随便写的一个求和函数 +def calc(a, b): + res = 0 + for i in range(a,b): + res += i + return res + + +if __name__ == '__main__': + a = calc(1, 101) + print(a) diff --git a/04/decorator/02.py b/04/decorator/02.py new file mode 100644 index 0000000..471f48f --- /dev/null +++ b/04/decorator/02.py @@ -0,0 +1,14 @@ +# 修改需求,现在每个函数在完成自己的功能之前,要先行打印字符串JRT +# 最简单的,修改函数定义即可 + + +def calc(a, b): + print('JRT') + res = 0 + for i in range(a, b): + res += i + return res + + +if __name__ == "__main__": + print(calc(1, 101)) diff --git a/04/decorator/03.py b/04/decorator/03.py new file mode 100644 index 0000000..1694866 --- /dev/null +++ b/04/decorator/03.py @@ -0,0 +1,24 @@ +# 可是刚才那么做是不是有点麻烦呀,函数多的话总不能一个一个修改 +# 所以我们可以写一个新函数 + + +def calc(a, b): + res = 0 + for i in range(a,b): + res += i + return res + + +def add(a, b): + return a + b + + +def func(f, a, b): + print("JRT") + return f(a, b) + + +if __name__ == '__main__': + print(func(calc, 1, 101)) + print(func(add, 1, 100)) + diff --git a/04/decorator/04.py b/04/decorator/04.py new file mode 100644 index 0000000..9547847 --- /dev/null +++ b/04/decorator/04.py @@ -0,0 +1,24 @@ +# 然而上次的做法本质上已经是定义新函数了,并不是我们想要的做法 + + +def calc(a, b): + res = 0 + for i in range(a, b): + res += i + return res + +# 定义装饰器 + + +def func(f): + def newF(a, b): + print('JRT') + return f(a, b) + return newF + + +# 应用装饰器 +calc = func(calc) + +if __name__ == '__main__': + print(calc(1, 101)) diff --git a/04/decorator/05.py b/04/decorator/05.py new file mode 100644 index 0000000..4dc2050 --- /dev/null +++ b/04/decorator/05.py @@ -0,0 +1,23 @@ +# Python也提供了自动装饰的语法糖 +# 定义装饰器 + + +def func(f): + def newF(a, b): + print('JRT') + return f(a, b) + return newF + + +# 使用Python为装饰器提供的语法糖,@后面是定义的装饰器,下一行紧跟要装饰的函数 +# Python会自动把待修饰函数做参数给装饰器,然后用装饰器返回的新函数覆盖待装饰的函数 +@func +def calc(a, b): + res = 0 + for i in range(a, b): + res += i + return res + + +if __name__ == '__main__': + print(calc(1, 101)) diff --git a/04/tkinter/05.py b/04/tkinter/05.py new file mode 100644 index 0000000..a909da8 --- /dev/null +++ b/04/tkinter/05.py @@ -0,0 +1,7 @@ +# 尚未完成 +from tkinter import * +# from math import * +window = Tk() +window.title("计算器") +window.geometry('1200x260') +window.mainloop() From 586e64d4ea35b27396b8f3ce83814ba0f706d01f Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sat, 17 Mar 2018 17:56:04 +0800 Subject: [PATCH 30/37] add indexSort.py --- test/indexSort.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/indexSort.py diff --git a/test/indexSort.py b/test/indexSort.py new file mode 100644 index 0000000..a91529f --- /dev/null +++ b/test/indexSort.py @@ -0,0 +1,12 @@ +def index_sort(seq): + seq = enumerate(seq) # 返回列表的索引-值对 + seq_index = [] + seq_value = [] + for i, j in seq: + seq_index.append(i) + seq_value.append(j) + return sorted(seq_index, key=lambda x:seq_value[x]) + + +if __name__ == '__main__': + print(index_sort((1, -2, 3, 99, 0, 22))) From 521754bd3064f20502810a6d97c4c479f32ebd8c Mon Sep 17 00:00:00 2001 From: caoxm-me Date: Sun, 18 Mar 2018 21:10:23 +0800 Subject: [PATCH 31/37] none --- 01/10-operator.py | 4 +- project/.idea/misc.xml | 4 + project/.idea/modules.xml | 8 + project/.idea/project.iml | 12 + project/.idea/workspace.xml | 236 ++++++++++++++++++ .../__pycache__/data_init.cpython-36.pyc" | Bin 0 -> 317 bytes .../__pycache__/data_sort.cpython-36.pyc" | Bin 0 -> 501 bytes .../__pycache__/data_store.cpython-36.pyc" | Bin 0 -> 503 bytes test/indexSort.py | 18 +- 9 files changed, 277 insertions(+), 5 deletions(-) create mode 100644 project/.idea/misc.xml create mode 100644 project/.idea/modules.xml create mode 100644 project/.idea/project.iml create mode 100644 project/.idea/workspace.xml create mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_init.cpython-36.pyc" create mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_sort.cpython-36.pyc" create mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_store.cpython-36.pyc" diff --git a/01/10-operator.py b/01/10-operator.py index 1ff98cb..6a93754 100644 --- a/01/10-operator.py +++ b/01/10-operator.py @@ -16,9 +16,9 @@ print("2<3:", 2 < 3) print("3>2:", 3 > 2) print("3=3:", 3 == 3) -print("5!=6:", 5 !=5) +print("5!=6:", 5 != 5) print("5>=4:", 5 >= 4) -print("5<=4:", 5 <= 4 ) +print("5<=4:", 5 <= 4) # 逻辑运算符:and or not print("not False = ", not False) print("False and True = ", False and True) diff --git a/project/.idea/misc.xml b/project/.idea/misc.xml new file mode 100644 index 0000000..3130edc --- /dev/null +++ b/project/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/project/.idea/modules.xml b/project/.idea/modules.xml new file mode 100644 index 0000000..a0733a5 --- /dev/null +++ b/project/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/project/.idea/project.iml b/project/.idea/project.iml new file mode 100644 index 0000000..6f63a63 --- /dev/null +++ b/project/.idea/project.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/project/.idea/workspace.xml b/project/.idea/workspace.xml new file mode 100644 index 0000000..fc2bff2 --- /dev/null +++ b/project/.idea/workspace.xml @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1521376901909 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_init.cpython-36.pyc" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_init.cpython-36.pyc" new file mode 100644 index 0000000000000000000000000000000000000000..92bf9b8031970d81846d968f980b5891dc94c404 GIT binary patch literal 317 zcmXr!<>eCfTpE?cz`*brh~a<<$Z`PUVjduo!jQt)!Vtxf!W7J)$(+mx6aoPd%?!lO zKwK;WBr+LlfGTYuG?NWbA4t7l6jxeiQE^FpUSe))6lYE%l(~{YlkpZyN@7W35y&Jk z@ihj>^0JC~HfPt`+Vylp|MT4~Pq#09vUg5QNNGuaQD$OJj8{;IZa`&8Mt&Y# zsGul6D>b| literal 0 HcmV?d00001 diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_sort.cpython-36.pyc" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_sort.cpython-36.pyc" new file mode 100644 index 0000000000000000000000000000000000000000..c21c563abbf659b4a4b02240149b21cbaa6864e3 GIT binary patch literal 501 zcmXr!<>eA{TN-7-$iVQJ0SPbx*$zNl%mXA+7*ZHp7@`hY|NWkxr^_e5*gxahjP*bb$g0yyb8_PI z5_40n6rQf%`E=KmC%gL4w7%Fk`DyFY7t0zU;?HNb0L^&1cKVYYYeDR_)1R%|3Nf-M zwWPEt&q^ULza%3wFC8ohCNvpuF{h`NXfoeo0lEJcE7*~@SU?u9WGG?Oh{=-eoIKQYwub}c4C!7b2EQVrG$TM&hu>(mzO-3*c Zb_f!|29&$SVUwGmQks)$2i67B1OOvBxfcKc literal 0 HcmV?d00001 diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_store.cpython-36.pyc" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_store.cpython-36.pyc" new file mode 100644 index 0000000000000000000000000000000000000000..72d98155f507908682fa2ec5da6337c50daf8302 GIT binary patch literal 503 zcmYjNO=}cE5UuL@$nLVy5OPq+ADDw4^cI3Fnp2QPVo+EngfTsdyY%ji-MwI>2LiiS zNg$^{AP@*4%-W98{Z=P?8L0XKp)v0*u$5S|d!3nGr3?XiLx?7;{M z?`=z?Va6M=HQ0I(v%)U|%?udd1S78qO(6he-Ja}!} z*zHQCw+Bf-wRMsFy+*zbR4%&OdhfcqbiQnuGr4=hyZI? pV@udXADe8ENtbL#tom6cDt9;NHa)Pl)qci@B7NkOQf>=P?>8}`j<)~+ literal 0 HcmV?d00001 diff --git a/test/indexSort.py b/test/indexSort.py index a91529f..cdd0369 100644 --- a/test/indexSort.py +++ b/test/indexSort.py @@ -1,12 +1,24 @@ -def index_sort(seq): +def index_sort1(seq): seq = enumerate(seq) # 返回列表的索引-值对 seq_index = [] seq_value = [] for i, j in seq: seq_index.append(i) seq_value.append(j) - return sorted(seq_index, key=lambda x:seq_value[x]) + return sorted(seq_index, key=lambda x: seq_value[x]) + +def index_sort2(seq): + seq = enumerate(seq) + seq_sorted = sorted(seq, key=lambda x: x[1]) + dict_sorted = dict(seq_sorted) + dict_key = dict_sorted.keys() + dict_value = dict_sorted.values() + return dict_key, dict_value if __name__ == '__main__': - print(index_sort((1, -2, 3, 99, 0, 22))) + print(index_sort1((1, -2, 3, 99, 0, 22))) + # print(index_sort2((1, -2, 3, 99, 0, 22))) + a, b = index_sort2((1, -2, 3, 99, 0, 22)) + print(a) + print(b) From 36d5af476d2aa571d3d8fb07b54f9824c6fad174 Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Mon, 19 Mar 2018 09:13:02 +0800 Subject: [PATCH 32/37] Update .gitignore --- .gitignore | 3 +- project/.idea/misc.xml | 4 - project/.idea/modules.xml | 8 - project/.idea/project.iml | 12 - project/.idea/workspace.xml | 236 ------------------ .../__pycache__/data_init.cpython-36.pyc" | Bin 317 -> 0 bytes .../__pycache__/data_sort.cpython-36.pyc" | Bin 501 -> 0 bytes .../__pycache__/data_store.cpython-36.pyc" | Bin 503 -> 0 bytes 8 files changed, 2 insertions(+), 261 deletions(-) delete mode 100644 project/.idea/misc.xml delete mode 100644 project/.idea/modules.xml delete mode 100644 project/.idea/project.iml delete mode 100644 project/.idea/workspace.xml delete mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_init.cpython-36.pyc" delete mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_sort.cpython-36.pyc" delete mode 100644 "project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_store.cpython-36.pyc" diff --git a/.gitignore b/.gitignore index 85e7c1d..3f1d055 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/.idea/ +.idea +__pycache__/ diff --git a/project/.idea/misc.xml b/project/.idea/misc.xml deleted file mode 100644 index 3130edc..0000000 --- a/project/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/project/.idea/modules.xml b/project/.idea/modules.xml deleted file mode 100644 index a0733a5..0000000 --- a/project/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/project/.idea/project.iml b/project/.idea/project.iml deleted file mode 100644 index 6f63a63..0000000 --- a/project/.idea/project.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/project/.idea/workspace.xml b/project/.idea/workspace.xml deleted file mode 100644 index fc2bff2..0000000 --- a/project/.idea/workspace.xml +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1521376901909 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_init.cpython-36.pyc" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_init.cpython-36.pyc" deleted file mode 100644 index 92bf9b8031970d81846d968f980b5891dc94c404..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 317 zcmXr!<>eCfTpE?cz`*brh~a<<$Z`PUVjduo!jQt)!Vtxf!W7J)$(+mx6aoPd%?!lO zKwK;WBr+LlfGTYuG?NWbA4t7l6jxeiQE^FpUSe))6lYE%l(~{YlkpZyN@7W35y&Jk z@ihj>^0JC~HfPt`+Vylp|MT4~Pq#09vUg5QNNGuaQD$OJj8{;IZa`&8Mt&Y# zsGul6D>b| diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_sort.cpython-36.pyc" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_sort.cpython-36.pyc" deleted file mode 100644 index c21c563abbf659b4a4b02240149b21cbaa6864e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 501 zcmXr!<>eA{TN-7-$iVQJ0SPbx*$zNl%mXA+7*ZHp7@`hY|NWkxr^_e5*gxahjP*bb$g0yyb8_PI z5_40n6rQf%`E=KmC%gL4w7%Fk`DyFY7t0zU;?HNb0L^&1cKVYYYeDR_)1R%|3Nf-M zwWPEt&q^ULza%3wFC8ohCNvpuF{h`NXfoeo0lEJcE7*~@SU?u9WGG?Oh{=-eoIKQYwub}c4C!7b2EQVrG$TM&hu>(mzO-3*c Zb_f!|29&$SVUwGmQks)$2i67B1OOvBxfcKc diff --git "a/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_store.cpython-36.pyc" "b/project/\345\247\223\345\220\215\346\243\200\347\264\242\347\263\273\347\273\237/__pycache__/data_store.cpython-36.pyc" deleted file mode 100644 index 72d98155f507908682fa2ec5da6337c50daf8302..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 503 zcmYjNO=}cE5UuL@$nLVy5OPq+ADDw4^cI3Fnp2QPVo+EngfTsdyY%ji-MwI>2LiiS zNg$^{AP@*4%-W98{Z=P?8L0XKp)v0*u$5S|d!3nGr3?XiLx?7;{M z?`=z?Va6M=HQ0I(v%)U|%?udd1S78qO(6he-Ja}!} z*zHQCw+Bf-wRMsFy+*zbR4%&OdhfcqbiQnuGr4=hyZI? pV@udXADe8ENtbL#tom6cDt9;NHa)Pl)qci@B7NkOQf>=P?>8}`j<)~+ From 9ecd8c6c1357e03e532161eb770bb230f0d396f8 Mon Sep 17 00:00:00 2001 From: UBWprayer <736002058@qq.com> Date: Mon, 19 Mar 2018 17:50:20 +0800 Subject: [PATCH 33/37] xingmingguanli --- test/UBWprayer/xingming.py | 168 +++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 test/UBWprayer/xingming.py diff --git a/test/UBWprayer/xingming.py b/test/UBWprayer/xingming.py new file mode 100644 index 0000000..408e38c --- /dev/null +++ b/test/UBWprayer/xingming.py @@ -0,0 +1,168 @@ +import pygame,sys,os +from pygame.locals import * + +xing_ming = {} +ming_xing = {} + +def clear():os.system('cls') + +def menu1(): + """显示主菜单""" + clear() + print('#' * 60) + print(' ' * 20,"欢迎使用姓名检索系统",' ' * 20) + print(' ' * 9,'\033[1;31;40m','1','\033[0m',".输入姓名",' '*18,"2 .查找姓名",' '*9) + print(' ' * 10,"3 .浏览姓名",' ' * 18,"4 .关闭程序",' ' * 9) + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_RIGHT: + menu2() + break + elif event.key == K_DOWN: + menu3() + break + elif event.key == K_KP_ENTER: + append() + break + return + +def menu2(): + clear() + print('#' * 60) + print(' ' * 20, "欢迎使用姓名检索系统", ' ' * 20) + print(' ' * 10, "1 .输入姓名", ' ' * 18, '\033[1;31;40m','2', '\033[0m', ".查找姓名", ' ' * 9) + print(' ' * 10, "3 .浏览姓名", ' ' * 18, "4 .关闭程序", ' ' * 9) + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_LEFT: + menu2() + break + elif event.key == K_DOWN: + menu4() + break + elif event.key == K_KP_ENTER: + find1() + break + return + +def menu3(): + clear() + print('#' * 60) + print(' ' * 20, "欢迎使用姓名检索系统", ' ' * 20) + print(' ' * 10, "1 .输入姓名", ' ' * 18, "2 .查找姓名", ' ' * 9) + print(' ' * 9,'\033[1;31;40m', '3', '\033[0m', ".浏览姓名", ' ' * 18, "4 .关闭程序", ' ' * 9) + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_UP: + menu1() + break + elif event.key == K_RIGHT: + menu4() + break + elif event.key == K_KP_ENTER: + show() + break + return + +def menu4(): + clear() + print('#' * 60) + print(' ' * 20, "欢迎使用姓名检索系统", ' ' * 20) + print(' ' * 10, "1 .输入姓名", ' ' * 18, "2 .查找姓名", ' ' * 9) + print(' ' * 10, "3 .浏览姓名", ' ' * 18, '\033[1;31;40m','4', '\033[0m', ".关闭程序", ' ' * 9) + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_UP: + menu2() + break + elif event.key == K_LEFT: + menu3() + break + elif event.key == K_KP_ENTER: + pygame.quit() + sys.exit() + break + return + +def append(): + clear() + print('#' * 60) + a = input(" 请输入姓氏(输入q退出):") + b = input(" 请输入名字(输入q退出):") + if a == 'q' or b == 'q': + menu1() + elif str(a) not in xing_ming and str(b) not in ming_xing: + xing_ming[str(a)] = str(b) + ming_xing[str(b)] = str(a) + print("输入成功!") + else: + print("您输入的名或姓已经与某一已经存在的姓名重复了哦。") + input("请按回车键退出") + menu1() + return + +def find1(): + clear() + print('#' * 60) + print(' ' * 20,"您要查找名还是姓?",' ' * 20) + print(' ' * 11, '\033[1;31;40m', '1', '\033[0m', ".姓氏", ' ' * 22, "2 .名字", ' ' * 11) + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_RIGHT: + find2() + break + elif event.key == K_KP_ENTER: + clear() + print('#' * 60) + a = input(' ' * 20,"请输入姓氏:") + if str(a) in xing_ming: + print(' ' * 10,"查找结果:",str(a),xing_ming[str(a)]) + input("请按回车键退出") + find1() + break + elif event.key == K_ESCAPE: + menu1() + break + return + +def find2(): + clear() + print('#' * 60) + print(' ' * 20, "您要查找名还是姓?", ' ' * 20) + print(' ' * 11, "1 .姓氏", ' ' * 22, '\033[1;31;40m', '2', '\033[0m', ".名字", ' ' * 11) + while True: + for event in pygame.event.get(): + if event.type == KEYDOWN: + if event.key == K_LEFT: + find1() + break + elif event.key == K_KP_ENTER: + clear() + print('#' * 60) + a = input(' ' * 20, "请输入名字:") + if str(a) in ming_xing: + print(' ' * 10, "查找结果:", ming_xing[str(a)], str(a)) + input("请按回车键退出") + find1() + break + elif event.key == K_ESCAPE: + menu1() + break + return + +def show(): + clear() + print('#' * 60) + print(xing_ming) + input("按回车键退出") + menu1() + return + +pygame.init() +screen=pygame.display.set_mode((640,360),0,32) +menu1() From b28ea622772af25d2aca7b815b67b6e7b3c4ccd7 Mon Sep 17 00:00:00 2001 From: UBWprayer <736002058@qq.com> Date: Mon, 19 Mar 2018 20:53:28 +0800 Subject: [PATCH 34/37] real functional name system --- test/UBWprayer/xingming.py | 178 ++++++++----------------------------- 1 file changed, 38 insertions(+), 140 deletions(-) diff --git a/test/UBWprayer/xingming.py b/test/UBWprayer/xingming.py index 408e38c..3ce0b8c 100644 --- a/test/UBWprayer/xingming.py +++ b/test/UBWprayer/xingming.py @@ -1,168 +1,66 @@ -import pygame,sys,os -from pygame.locals import * - +# 变量定义部分 xing_ming = {} ming_xing = {} -def clear():os.system('cls') - -def menu1(): +# 函数定义部分 +def menu(): """显示主菜单""" - clear() print('#' * 60) print(' ' * 20,"欢迎使用姓名检索系统",' ' * 20) - print(' ' * 9,'\033[1;31;40m','1','\033[0m',".输入姓名",' '*18,"2 .查找姓名",' '*9) + print(' ' * 10,"1 .输入姓名",' '*18,"2 .查找姓名",' '*9) print(' ' * 10,"3 .浏览姓名",' ' * 18,"4 .关闭程序",' ' * 9) - while True: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_RIGHT: - menu2() - break - elif event.key == K_DOWN: - menu3() - break - elif event.key == K_KP_ENTER: - append() - break - return - -def menu2(): - clear() - print('#' * 60) - print(' ' * 20, "欢迎使用姓名检索系统", ' ' * 20) - print(' ' * 10, "1 .输入姓名", ' ' * 18, '\033[1;31;40m','2', '\033[0m', ".查找姓名", ' ' * 9) - print(' ' * 10, "3 .浏览姓名", ' ' * 18, "4 .关闭程序", ' ' * 9) - while True: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_LEFT: - menu2() - break - elif event.key == K_DOWN: - menu4() - break - elif event.key == K_KP_ENTER: - find1() - break - return - -def menu3(): - clear() - print('#' * 60) - print(' ' * 20, "欢迎使用姓名检索系统", ' ' * 20) - print(' ' * 10, "1 .输入姓名", ' ' * 18, "2 .查找姓名", ' ' * 9) - print(' ' * 9,'\033[1;31;40m', '3', '\033[0m', ".浏览姓名", ' ' * 18, "4 .关闭程序", ' ' * 9) - while True: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_UP: - menu1() - break - elif event.key == K_RIGHT: - menu4() - break - elif event.key == K_KP_ENTER: - show() - break - return - -def menu4(): - clear() - print('#' * 60) - print(' ' * 20, "欢迎使用姓名检索系统", ' ' * 20) - print(' ' * 10, "1 .输入姓名", ' ' * 18, "2 .查找姓名", ' ' * 9) - print(' ' * 10, "3 .浏览姓名", ' ' * 18, '\033[1;31;40m','4', '\033[0m', ".关闭程序", ' ' * 9) - while True: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_UP: - menu2() - break - elif event.key == K_LEFT: - menu3() - break - elif event.key == K_KP_ENTER: - pygame.quit() - sys.exit() - break - return + a = input(">") + if int(a) == 1: + append() + elif int(a) == 2: + find() + elif int(a) == 3: + show() + elif int(a) == 4: + return def append(): - clear() print('#' * 60) a = input(" 请输入姓氏(输入q退出):") b = input(" 请输入名字(输入q退出):") if a == 'q' or b == 'q': - menu1() + menu() elif str(a) not in xing_ming and str(b) not in ming_xing: xing_ming[str(a)] = str(b) ming_xing[str(b)] = str(a) print("输入成功!") else: print("您输入的名或姓已经与某一已经存在的姓名重复了哦。") - input("请按回车键退出") - menu1() + input("请按回车键返回上一级") + menu() return -def find1(): - clear() +def find(): print('#' * 60) print(' ' * 20,"您要查找名还是姓?",' ' * 20) - print(' ' * 11, '\033[1;31;40m', '1', '\033[0m', ".姓氏", ' ' * 22, "2 .名字", ' ' * 11) - while True: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_RIGHT: - find2() - break - elif event.key == K_KP_ENTER: - clear() - print('#' * 60) - a = input(' ' * 20,"请输入姓氏:") - if str(a) in xing_ming: - print(' ' * 10,"查找结果:",str(a),xing_ming[str(a)]) - input("请按回车键退出") - find1() - break - elif event.key == K_ESCAPE: - menu1() - break - return - -def find2(): - clear() - print('#' * 60) - print(' ' * 20, "您要查找名还是姓?", ' ' * 20) - print(' ' * 11, "1 .姓氏", ' ' * 22, '\033[1;31;40m', '2', '\033[0m', ".名字", ' ' * 11) - while True: - for event in pygame.event.get(): - if event.type == KEYDOWN: - if event.key == K_LEFT: - find1() - break - elif event.key == K_KP_ENTER: - clear() - print('#' * 60) - a = input(' ' * 20, "请输入名字:") - if str(a) in ming_xing: - print(' ' * 10, "查找结果:", ming_xing[str(a)], str(a)) - input("请按回车键退出") - find1() - break - elif event.key == K_ESCAPE: - menu1() - break - return + print(' ' * 11,"1 .姓氏", ' ' * 22, "2 .名字", ' ' * 11) + print("输入q返回上一级") + a = input(">") + if int(a) == 1: + b = input("请输入您要查找的姓氏:") + if str(b) in xing_ming: + print("查找结果:",b,xing_ming[b]) + if int(a) == 2: + b = input("请输入您要查找的名字:") + if str(b) in ming_xing: + print("查找结果:",ming_xing[b],b) + input("请按回车键返回上一级") + menu() + return def show(): - clear() print('#' * 60) - print(xing_ming) - input("按回车键退出") - menu1() + print(' ' * 20 ,"姓氏" , ' ' * 12,"名字") + for i in xing_ming: + print(' '*20,i,' '*14,xing_ming[i]) + input("按回车键返回上一级") + menu() return -pygame.init() -screen=pygame.display.set_mode((640,360),0,32) -menu1() +# 函数调用 +menu() From 25a6a568a8702b0bb4982d016f12991932dcfeb1 Mon Sep 17 00:00:00 2001 From: guono912 <32875133+guono912@users.noreply.github.com> Date: Tue, 20 Mar 2018 16:56:05 +0800 Subject: [PATCH 35/37] Add files via upload --- test/guono912/name_v1.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/guono912/name_v1.py diff --git a/test/guono912/name_v1.py b/test/guono912/name_v1.py new file mode 100644 index 0000000..371a6ee --- /dev/null +++ b/test/guono912/name_v1.py @@ -0,0 +1,39 @@ +#读入txt文件,分姓名保存 +xing = [] +ming = [] +with open('name.txt') as f: + for line1 in f: + x , m = line1.split() + xing.append(x) + ming.append(m) +#遍历查找 +print('输入查找类型') +print('按姓查找输入1,按名输入2,按姓名查找输入3') +i = input() +print('请输入查找目标') +ser = input() +num = 0 +if i == '1': + for j in range(0,len(xing)): + if ser == xing[j]: + print(xing[j],ming[j]) + num = num+1 + if num == 0: + print('没有结果') +elif i == '2': + for j in range(0,len(ming)): + if ser == ming[j]: + print(xing[j],ming[j]) + num = num+1 + if num == 0: + print('没有结果') +elif i == '3': + x , m=ser.split() + for j in range(0,len(xing)): + if x == xing[j] and m == ming[j]: + print(xing[j],ming[j]) + num = num+1 + if num == 0: + print('没有结果') +else: + print('输入不合法') From 260a3f26fdad53cfd18396faf3d4e925238e7de0 Mon Sep 17 00:00:00 2001 From: huge-star <30525493+huge-star@users.noreply.github.com> Date: Sun, 25 Mar 2018 15:47:54 +0800 Subject: [PATCH 36/37] =?UTF-8?q?=E8=BF=99=E6=A0=B7=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes test/.DS_Store | Bin 0 -> 6148 bytes test/huge-star(fanxilai)/Caculator_By_fxl.py | 77 +++++++++++++++++++ test/huge-star(fanxilai)/Index_S.py | 9 +++ test/huge-star(fanxilai)/Name_Store.py | 74 ++++++++++++++++++ 5 files changed, 160 insertions(+) create mode 100644 .DS_Store create mode 100644 test/.DS_Store create mode 100644 test/huge-star(fanxilai)/Caculator_By_fxl.py create mode 100644 test/huge-star(fanxilai)/Index_S.py create mode 100644 test/huge-star(fanxilai)/Name_Store.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6431a943b4fdb3f7c38cd9784e8ffa1c9d5ef3c4 GIT binary patch literal 6148 zcmeHK!A{#i5SjePO>cqEtp0(_|YwX5rsffZkmN>d@Fv<*D)h8V|};0mNB1I5#+Aa+(I`-r&qb7kVJ! z96E3c#WY(S8f+I1U=Mbn4etFIq~oJAaekTRXbVe~QS4329{yD}@n zB!(nryzUFOhjn=&3<|c;CH*ZHH*I8a| zZ1103e7hW8jjq3A&1eGubIKMO$8d|mq`t2~FH2?i1^dSQG0&n^z$)-^72y5AS$Me; z*vhQ}R)HrJp#8x^C-fOhjcV(_MqL3AtJtj!WBUB39FNgwEH&Z?n$W3;I#uu$L+Etu z_n7B1mKt?B2)=v>URm%BMX1$reoxUs_!@0%6|f3SD=?!UYjpnaJ$?V5PO?u{0jt1& zrGTimgLVr`;>iBUO`ue{T>B~K4Ym7d(iBMfRe#B JR)J?#;5WAmS6n}05juq$X5e3AK%JYeYD#~|x%XSQYmePVcQ<$W z4)-J5^&6pdcAW-HcD7vK;oS<4eWxSGv62oMXg9am@2{>ER?JdquwwQ%HlVKFS|1FI z?Bey}?ajS*?^*x(;Kf_46vA*iOIc8O1n;2CxO%TywCcPa9J$W!+2+-%6GwHTZ$C1x zKY#cWPv?Z5LF=TmJ+MOG<9-vf6s(;`{)o(PAfGH`Wr!@BlKJctY}1)Z52d32zXPXJ&B%~GI?9|7TODl97;CWsygOI(48D^pJl zmbjzcRCZ;B!vqs|V(Rh1RAi=JC`?Aj_@*=`R!&gYngPwgCiu z&46a$zhZ!8s#djvC8@i0VsYZGHBt6Zgb2G~g3<+*x{jqHuHvgGQqX4#1z1)%Ob{&) P{Uac0(3NK3uQKopS2YI7 literal 0 HcmV?d00001 diff --git a/test/huge-star(fanxilai)/Caculator_By_fxl.py b/test/huge-star(fanxilai)/Caculator_By_fxl.py new file mode 100644 index 0000000..d7f1a0e --- /dev/null +++ b/test/huge-star(fanxilai)/Caculator_By_fxl.py @@ -0,0 +1,77 @@ +# exp = raw_input("Please input your expression >>> ") +operator = ['^', '/', '*', '-', '+'] +# exp = str(input("Please input your expression >>> ")) +# exp = exp.split(' ') +# j = 0 +# for i in range(len(exp)): +# if exp[i].isdigit(): +# dgt[j] = exp.pop(0) +# j += 1 +# elif exp[i] in operator: +# op[k] = exp.pop(0) +# k += 1 +# +# +# exp = str(input("Please input your expression >>> ")).split() +# while (len(exp) - 1): +# while '^' in exp: +# index = exp.index('^') +# exp.pop(index) +# exp.insert(index - 1, int(exp.pop(index - 1)) ** int(exp.pop(index - 1))) + +# 以上都是废代码 +operator = ['^', '/', '*', '-', '+'] # 定义一个列表来存储符号,方便下面用循环。 +def compute(exp): + ''' + 以处理好的已经把运算符和数字分割好的、并以他们作为元素的列表作为输入,计算出所给表达式的值(不带括号) + :param exp: + :return: + ''' + while (len(exp) - 1): # 当表达式的值没有被撇的只剩一个的时候(见列表的pop()方法) + for op in iter(operator): # 从operator列表里按顺序取元素,注意operator列表中的元素顺序应是运算符的运算顺序。 + while op in exp: + index = exp.index(op) # 存储下要计算的预算符的位置 + exp.pop(index) + if op == '^': + exp.insert(index - 1, float(exp.pop(index - 1)) ** float(exp.pop(index - 1))) + # 这四个插入(insert)是同样的道理。拿出运算符左边的(exp.pop(index - 1))和右边的(exp.pop(index - 1)\ + # 并把他们强制转化为float(精度高)然后运算得出结果并把它插入到被撇掉的那三个的位置。 + if op == '/': + exp.insert(index - 1, float(exp.pop(index - 1)) / float(exp.pop(index - 1))) + if op == '*': + exp.insert(index - 1, float(exp.pop(index - 1)) * float(exp.pop(index - 1))) + if op == '-': + exp.insert(index - 1, float(exp.pop(index - 1)) - float(exp.pop(index - 1))) + if op == '+': + exp.insert(index - 1, float(exp.pop(index - 1)) + float(exp.pop(index - 1))) + # 这里的四个判断是迫不得已才写的,本来想直接用一个循环了事,但是那样的话,比如"float(exp.pop(index - 1)) + # + float(exp.pop(index - 1)"中的运算符就没办法更改,所以最后我只想到了判断这一种方法。 + return exp[0] + +def recur_parenth(exp): + ''' + 通过递归来一层层(从最外层到最里层)去括号,然后再一层层(从最里层到最外层)把值返回回来。 + :param exp: + :return: + ''' + if '(' in exp: + index1 = exp.index('(') + exp.pop(index1) + exp.reverse() + index2 = len(exp) - exp.index(')') - 1 + exp.reverse() + exp.pop(index2) # 这些步骤主要是找到一对儿括号并用index1和index2标记出他们的位置,然后从exp中撇掉'('和')',其中reverse()也是\ + # 想不出别的好方法的无奈之举。 + exp[index1:index2] = [recur_parenth(exp[index1:index2])] # 截取原来包含在括号中的部分,并计算它们的值 + return compute(exp) + return compute(exp) # 递归出口,当exp没有括号只有表达式时,返回该表达式之值。 + + + +exp = str(input("Please input your expression with spaces to separate your numbers from operator >>> ")).split() +# 输入表达式并用字符串的split()方法把他们分隔开(split()方法的默认参数是split(' '),故省略) +print(recur_parenth(exp)) + +# 这个程序有一个巨大的缺陷,就是必须要用空格来区分开符号与数字,这样的话就十分的僵硬,慢慢儿改进把。 +# 还有一个缺陷是算不了太大的数 +# 另一个缺陷是没有错误提醒 diff --git a/test/huge-star(fanxilai)/Index_S.py b/test/huge-star(fanxilai)/Index_S.py new file mode 100644 index 0000000..c94e794 --- /dev/null +++ b/test/huge-star(fanxilai)/Index_S.py @@ -0,0 +1,9 @@ +def index_sort(l): + o = [] + m = list(zip(l, range(3))) + m.sort() + for (i, value) in m: + o.append(value) + return o + +print(index_sort([12,56,33,78])) diff --git a/test/huge-star(fanxilai)/Name_Store.py b/test/huge-star(fanxilai)/Name_Store.py new file mode 100644 index 0000000..52b2a1f --- /dev/null +++ b/test/huge-star(fanxilai)/Name_Store.py @@ -0,0 +1,74 @@ +def name_input(): + ''' + Enter white space seoarated name and return the tuple (first name, last name) + :return: tuple (first name, last name) + ''' + flag = 1 + while flag: + try: + [fn, ln] = input("\nPlease enter the name >>> ").split() + flag = 0 + except: + print("\nPlease check your name") + return fn.lower(), ln.lower() # 用于不区分大小写 + + +def choose_action(): + ''' + print instructions on the screen and return the action user chooose + :return: int + ''' + while 1: + tag = int(input("\nWhat would you like to do?\n0. quit\n1. record\n2. search\n>>> ")) + if tag == 0 or tag == 1 or tag == 2: + return tag + else: + print("\nPlease enter the right number!") + + +def search_input(): + ''' + 用来输入要搜索的名字 + :return: tuple (name, tag) + ''' + tag = 1 # 用来标记动作 + while tag: + tag = int(input("\nWhich name do you want to search?\n0. quit\n1. first name\n2. last name\n>>> ")) + if not tag: + return '', tag + name = input("\nPlease enter the name >>> ") + return name, tag + + +def search_name(name, tag): + result = set({}) # 新建一个空集合来存放结果 + global name_book + for n in name_book: + if n[tag-1] == name.lower(): # 不区分大小写 + result.add(n) + return result + + +def print_set(result): + ''' + 搜索结果是一个set,用来打印搜索结果(set) + :param result: set + :return: void + ''' + for i in result: + print("%s %s" % (i[0], i[1])) + + +def start_program(): + flag = 1 # 用来标记程序结束 + name_book = set() # 这里用set是因为我想不到什么用字典的好方法了,就蒙了一个集合,在网上一找,发现python还真有这个内建数据类型,于是就很开心的使用了 + while flag: + flag = choose_action() # 同时用来标记应该进行的动作 + if flag == 1: + name_book.add(name_input()) # add是set类型的一个方法,添加元素到集合 + elif flag == 2: + i = search_input() + if i[1] == 0: + continue; + print_set(search_name(i[0], i[1])) + From 0c8c65a23a2c79a8d3ef38059bd73f5da242390b Mon Sep 17 00:00:00 2001 From: metal A-wing Date: Sun, 25 Mar 2018 21:28:25 +0800 Subject: [PATCH 37/37] Remove .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + 2 files changed, 1 insertion(+) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 6431a943b4fdb3f7c38cd9784e8ffa1c9d5ef3c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!A{#i5SjePO>cqEtp0(_|YwX5rsffZkmN>d@Fv<*D)h8V|};0mNB1I5#+Aa+(I`-r&qb7kVJ! z96E3c#WY(S8f+I1U=Mbn4etFIq~oJAaekTRXbVe~QS4329{yD}@n zB!(nryzUFOhjn=&3<|c;CH*ZHH*I8a| zZ1103e7hW8jjq3A&1eGubIKMO$8d|mq`t2~FH2?i1^dSQG0&n^z$)-^72y5AS$Me; z*vhQ}R)HrJp#8x^C-fOhjcV(_MqL3AtJtj!WBUB39FNgwEH&Z?n$W3;I#uu$L+Etu z_n7B1mKt?B2)=v>URm%BMX1$reoxUs_!@0%6|f3SD=?!UYjpnaJ$?V5PO?u{0jt1& zrGTimgLVr`;>iBUO`ue{T>B~K4Ym7d(iBMfRe#B JR)J?#;5W