Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

测试 #53

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
0c70cda
Create cover.jpg
JQ-K Oct 15, 2015
6c6f5dd
Update SUMMARY.md
JQ-K Oct 15, 2015
262dd83
Update SUMMARY.md
JQ-K Oct 15, 2015
995fb08
Update SUMMARY.md
JQ-K Oct 15, 2015
1fcb433
Update 0MOOC/README.md
JQ-K Oct 15, 2015
d9f6ef2
Create 0MOOC/11_week0ff1a_liang_cao_wei_dong_ff0c_bing_ma_xian_xing.md
JQ-K Oct 15, 2015
ba7c38b
Update SUMMARY.md
JQ-K Oct 15, 2015
0cc5dd5
Update 0MOOC/11_week0ff1a_liang_cao_wei_dong_ff0c_bing_ma_xian_xing.md
JQ-K Oct 15, 2015
0ed5a1e
Update SUMMARY.md
JQ-K Oct 15, 2015
df0d678
Update 0MOOC/11_week0ff1a_liang_cao_wei_dong_ff0c_bing_ma_xian_xing.md
JQ-K Oct 15, 2015
69102d2
Update SUMMARY.md
JQ-K Oct 15, 2015
945e3cd
Create 0MOOC/11guan_yu_git_zhong_zhong.md
JQ-K Oct 15, 2015
cf41b0c
Update SUMMARY.md
JQ-K Oct 15, 2015
93d146f
Delete 0MOOC/11guan_yu_git_zhong_zhong.md
JQ-K Oct 15, 2015
7f0633e
Update SUMMARY.md
JQ-K Oct 15, 2015
dde3c47
Update SUMMARY.md
JQ-K Oct 15, 2015
33402a5
Create 0MOOC/guan_yu_git_zhong_zhong.md
JQ-K Oct 15, 2015
4ede95e
Update SUMMARY.md
JQ-K Oct 15, 2015
13360d7
Update book.json
JQ-K Oct 15, 2015
a3bed07
Update book.json
JQ-K Oct 15, 2015
34ece74
Update book.json
JQ-K Oct 15, 2015
1c2b833
Update SUMMARY.md
JQ-K Oct 21, 2015
838cc60
Update SUMMARY.md
JQ-K Oct 21, 2015
e843f84
Create 1sTry/2.1 kai_shi_bian_cheng.md
JQ-K Oct 21, 2015
faf90fe
Update SUMMARY.md
JQ-K Oct 21, 2015
2cbcedc
Update SUMMARY.md
JQ-K Oct 21, 2015
dacd0d0
Update SUMMARY.md
JQ-K Oct 21, 2015
a8ef1fb
Create 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 21, 2015
c7cc177
Update SUMMARY.md
JQ-K Oct 21, 2015
77a3a56
Update 1sTry/README.md
JQ-K Oct 21, 2015
b4b6e28
Update 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 21, 2015
e82b2ba
Create 1sTry/help(file).png
JQ-K Oct 21, 2015
21a2283
Update 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 21, 2015
340e0c6
Update 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 21, 2015
2a4ae94
Update 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 21, 2015
566cb17
编程作业
JQ-K Oct 23, 2015
b5d0c16
Merge branch 'master' of https://github.com/JQ-K/OMOOC2py
JQ-K Oct 23, 2015
b3bbb51
Update SUMMARY.md
JQ-K Oct 24, 2015
40f4a20
Update SUMMARY.md
JQ-K Oct 24, 2015
83a80b5
Update SUMMARY.md
JQ-K Oct 24, 2015
78e3c08
Update SUMMARY.md
JQ-K Oct 24, 2015
f40f494
Update SUMMARY.md
JQ-K Oct 24, 2015
709bb92
Update SUMMARY.md
JQ-K Oct 24, 2015
fe337d1
Update SUMMARY.md
JQ-K Oct 24, 2015
f478452
Update SUMMARY.md
JQ-K Oct 24, 2015
ba1bb38
Update SUMMARY.md
JQ-K Oct 24, 2015
503ca53
Update SUMMARY.md
JQ-K Oct 24, 2015
cda0c4c
Create 0MOOC/zhun_bei_gong_zuo.md
JQ-K Oct 24, 2015
807ccf9
Update SUMMARY.md
JQ-K Oct 24, 2015
da5424f
Update 0MOOC/11_week0ff1a_liang_cao_wei_dong_ff0c_bing_ma_xian_xing.md
JQ-K Oct 24, 2015
f6e75c8
Update 0MOOC/zhun_bei_gong_zuo.md
JQ-K Oct 24, 2015
c9a5253
Delete 0MOOC/11_week0ff1a_liang_cao_wei_dong_ff0c_bing_ma_xian_xing.md
JQ-K Oct 24, 2015
f07efd3
Update SUMMARY.md
JQ-K Oct 24, 2015
6c89bbc
Delete 0MOOC/guan_yu_git_zhong_zhong.md
JQ-K Oct 24, 2015
8e61bb9
Update SUMMARY.md
JQ-K Oct 24, 2015
4033400
Update SUMMARY.md
JQ-K Oct 24, 2015
80f5cd9
Create 0MOOC/linux_command_line.md
JQ-K Oct 24, 2015
e5a21f9
Update SUMMARY.md
JQ-K Oct 24, 2015
4b12e5d
Update 0MOOC/linux_command_line.md
JQ-K Oct 24, 2015
f3defa9
Update SUMMARY.md
JQ-K Oct 24, 2015
b24d49d
Update 0MOOC/linux_command_line.md
JQ-K Oct 24, 2015
279ee4c
Update 0MOOC/linux_command_line.md
JQ-K Oct 24, 2015
690d5ab
second
JQ-K Oct 25, 2015
7de2108
测试
JQ-K Oct 25, 2015
000f9fd
Update 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 25, 2015
bf75b3e
Update 1sTry/211_xiao_ri_ji_ren_wu.md
JQ-K Oct 25, 2015
d2d0624
Update SUMMARY.md
JQ-K Nov 16, 2015
699d337
Update SUMMARY.md
JQ-K Nov 16, 2015
b8b7bbb
Update SUMMARY.md
JQ-K Nov 16, 2015
b6c22b5
Update SUMMARY.md
JQ-K Nov 16, 2015
6900020
Update SUMMARY.md
JQ-K Nov 16, 2015
4c01084
Delete 1sTry/2.1 kai_shi_bian_cheng.md
JQ-K Nov 16, 2015
50d61d9
Update SUMMARY.md
JQ-K Nov 16, 2015
149a7e0
Update SUMMARY.md
JQ-K Nov 17, 2015
ff5170f
Update SUMMARY.md
JQ-K Nov 17, 2015
f8b8625
Update SUMMARY.md
JQ-K Nov 17, 2015
5ee7fcf
Update SUMMARY.md
JQ-K Nov 17, 2015
5f626bd
Create sui_shou_ji.md
JQ-K Nov 17, 2015
3e42b48
Update SUMMARY.md
JQ-K Nov 17, 2015
37a8a1b
Update SUMMARY.md
JQ-K Nov 17, 2015
78cfb80
Update SUMMARY.md
JQ-K Nov 17, 2015
2df0e82
Update sui_shou_ji.md
JQ-K Nov 17, 2015
f9efa09
Update SUMMARY.md
JQ-K Nov 17, 2015
fb278e8
Update SUMMARY.md
JQ-K Nov 17, 2015
670ab22
Create python_socket_network_programming.md
JQ-K Nov 17, 2015
af3c649
Update SUMMARY.md
JQ-K Nov 17, 2015
ffec16d
Update SUMMARY.md
JQ-K Nov 17, 2015
53d8069
Update python_socket_network_programming.md
JQ-K Nov 17, 2015
2d187d1
events and bindings
JQ-K Apr 1, 2016
62cb1eb
examples
JQ-K Apr 1, 2016
aaee6e2
update
JQ-K Apr 3, 2016
815e9f6
update2
JQ-K Apr 3, 2016
cd71bdf
good 简洁版本 利用了Text
JQ-K Apr 3, 2016
20d30bf
参考别人的代码
JQ-K May 30, 2016
6942d88
what
JQ-K May 30, 2016
af5d866
bottle de用法 来自大妈
JQ-K May 30, 2016
96921bb
任务说明
JQ-K May 30, 2016
526e5fb
“客户端”
JQ-K Jun 2, 2016
88e8e12
代码解说
JQ-K Jun 3, 2016
8e675e8
服务端
JQ-K Jun 4, 2016
79a6818
note
JQ-K Jun 4, 2016
9ce0b52
html
JQ-K Jun 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions 0MOOC/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# 0MOOC
~ 此目录收集, 课程进入时的体验

## 进展
#Week0:兵马未动粮草先行
#

- 150924 大妈创建
5 changes: 5 additions & 0 deletions 0MOOC/linux_command_line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# 常用命令

> 链接 http://locez.com/Linux/common-command/

25 changes: 25 additions & 0 deletions 0MOOC/zhun_bei_gong_zuo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 准备工作


## 生命不息,折腾不止——系统篇

* 入班之前就听闻win系统编程不方便,试用几天果不其然,于是,决定装Linux(Ubuntu)。一通折腾,说好的U盘引导安装在我这愣是装不上,誓不罢休,wubi法安装,遂成。种种折磨,就差砸电脑了。

* 网上教程很多,但良莠不齐,因为水平差异&脑回路不同有些教程逻辑跳跃,官方Help是大杀器,小白的福利:-D

## 生命不息,折腾不止——科学上网篇

*
不翻墙情况下,试了下Github,可以打开但不流畅,关键是Google&Gmail没法用,不能忍。购买Shadowsocks按照教程安装,Win上可以用各种爽。Ubuntu下配置有点复杂,几经摸索配置妥当就是死活连不上——崩溃(我不是系统)反复检查发现不是设置问题,应该是墙修高了。搜索,发现了一个利器——Lantern,遂用,好使,开心:-D

*
多巴胺的分泌多寡跟你前期投入多少看来有时候是正相关的









46 changes: 46 additions & 0 deletions 1sTry/211_xiao_ri_ji_ren_wu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 2.1.1 小日记任务

## 任务描述

> 完成一个极简交互式日记系统,需求如下:
> * 一次接收输入一行日记
* 保存为本地文件
* 再次运行系统时,能打印出过往的所有日


### 挖坑:
1. 如何向文本添加内容不删除或者覆盖原来内容

2. 读写文件的基础知识

3. 如何每次记录每次写完日记的时间,且在下次打开系统时能展示

4. 文本换行

5.打开系统自动打印之前的所有记录,如果没有这个文件进行创建


### 基本思路:

>* 代码不只是自己使用,别人第一次运行要确保其能创建一个新的日记文件并且保存

> * 所以代码第一部分需要判断有没有这个日记文件,需要用到 os.path.exists()命令进行判断

> * 如果存在打开读取文件不存在创建文件使 if 函数,打开读取使用open/read 命令

> 代码如下

> coding:utf-8
from sys import argv
import time
import os
script, filename = argv
E = os.path.exists(filename)
if str(E) == 'True':
print txt.read()
else:
print '尚无 %r ---创建之...' % filename



>* 第二大块内容是写入需用 raw_input().
2 changes: 1 addition & 1 deletion 1sTry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

## 进展

- 150924 大妈创建
- 150924 大妈创
Binary file added 1sTry/help(file).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Summary
- [教学反转](0MOOC/README.md)
- [基础旋进](1sTry/README.md)
- [迭代作品](2nDev/README.md)
- [人生首秀](3rDemo/README.md)
- [代码 (_src)](_src/README.md)
- [素材 (draft)](draft/README.md)
+ [教程该怎么写](draft/how2tutorial.md)
- [有关](ABOUT.md)

* [Introduction](README.md)
* [随手记](sui_shou_ji.md)
* Python异常处理
* Python socket network programming
* [1.教学反转](0MOOC/README.md)
* [准备工作](0MOOC/zhun_bei_gong_zuo.md)
* [Linux command line](0MOOC/linux_command_line.md)
* [2. 基础旋进](1sTry/README.md)
* [迭代作品](2nDev/README.md)
* [人生首秀](3rDemo/README.md)
* [代码 (_src)](_src/README.md)
* [素材 (draft)](draft/README.md)
* [教程该怎么写](draft/how2tutorial.md)
* [有关](ABOUT.md)

13 changes: 13 additions & 0 deletions _src/om2py0w/0wex1/ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

f
---2015-10-25 Sunday 11:14:10 CST
测试2
---2015-10-25 Sunday 11:21:56 CST
w
---2015-10-25 Sunday 11:27:45 CST
2
---2015-10-25 Sunday 11:28:51 CST

---2015-10-25 Sunday 11:29:04 CST
woshi
---2015-10-25 Sunday 14:02:02 CST
12 changes: 12 additions & 0 deletions _src/om2py0w/0wex1/gui/bind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from Tkinter import *

root = Tk()

def callback(event):
print "clicked at", event.x, event.y

frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", callback)
frame.pack()

root.mainloop()
8 changes: 8 additions & 0 deletions _src/om2py0w/0wex1/gui/hello1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from Tkinter import *

root = Tk() #You should only create one root widget for each program, and it must be created before any other widgets.

w = Label(root, text="Hello, world!") #create a Label widget as a child to the root window:
w.pack()

root.mainloop()
26 changes: 26 additions & 0 deletions _src/om2py0w/0wex1/gui/hello2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from Tkinter import *

class App:

def __init__(self, master):

frame = Frame(master)
frame.pack()

self.button = Button(
frame, text="QUIT", fg="red", command=frame.quit
)
self.button.pack(side=LEFT)

self.hi_there = Button(frame, text="Hello", command=self.say_hi)
self.hi_there.pack(side=LEFT)

def say_hi(self):
print "hi there, everyone!"

root = Tk()

app = App(root)

root.mainloop()
root.destroy() # optional; see description below
46 changes: 46 additions & 0 deletions _src/om2py0w/0wex1/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# coding:utf-8 #解决中文字符问题
from sys import argv
import time #导入time 模块
import os

script, filename = argv
E = os.path.exists(filename) #判断filename是否存在

if str(E) == 'True': #str 可将数据转化为字符串
txt = open(filename) #读取内容需先将其打开
print '这是 %r 的内容:' % filename
print txt.read() # 每次运行自动打印之前的记录
else:
print '尚无 %r ---创建之...' % filename

# ---以下输入内容并保存---


print "If you don't want that, hit CTRL-C (^C)."
print "IF you do want this, hit return."

raw_input('> ')

print "Opening the file..."
target = open(filename,"a") # 'a' 表示要向文件写入数据,但是添加到当前内容尾部


print "输入新的内容:"

content = raw_input("line 1: ")

T = time .strftime('%Y-%m-%d %A %X %Z', time.localtime()) # 显示当下时间

print T

print "I'm going to write these to the file."

target.write('\n' + content + '\n' + "---"+ T)


print "And finally, we close it."
target = open(filename)

print target.read()
target.close()
# txt.close() # close 能否不用?
42 changes: 42 additions & 0 deletions _src/om2py0w/0wex1/mytkinter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# coding=utf-8
from Tkinter import *
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from jqk_dairy import *

root = Tk()
root.title("kang's diary")#命名
root.geometry('400x400')#尺寸
w = Label(root, text="Welcom to kang's diary", pady=20)#输入框的设置

w.pack()#显示输入框

var = StringVar(value="What do you want to write today?")#字符变量StringVar跟踪变量值的变化

text_input = Entry(root, textvariable=var,width=36)
text_input.pack()

def print_content():
append_text(var.get())
text_output.config(text=get_text())
var.set('')

#text_input = Entry(root)
#text_input.insert(0, "Hi, what's up")
#text_input.pack()

#def print_content():
#print text_input.get()
#text_input.delete(0,'end')

button = Button(root, text="print", command=print_content)
button.pack()

root.bind('<Return>', lambda event:print_content())

text_output = Message(root, textvariable=var, width=360,pady=20)
text_output.pack()


root.mainloop()
37 changes: 37 additions & 0 deletions _src/om2py0w/0wex1/mytkinter2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding=utf-8

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import Tkinter as tk
from jqk_dairy import *


def enter_and_print(event):
append_text(var.get())
text_output.delete(0.0,'end')
text_output.insert(0.0,get_text())
var.set('')


root = tk.Tk()
root.title("kang's diary")

var = tk.StringVar(value="What do you want to write today?")

text_input = tk.Entry(root, textvariable=var, width=36, bd=5)
text_input.pack()

root.bind('<Return>', enter_and_print)

text_output = tk.Text(root,width=46)
text_output.pack(side='left', fill='y')

s =tk.Scrollbar(root)
s.pack(side='right', fill='y')

s.config(command=text_output.yview)
text_output.config(yscrollcommand=s.set)

root.mainloop()
35 changes: 35 additions & 0 deletions _src/om2py3w/3wex0/c1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
import socket
import sys,codecs
reload(sys)
sys.setdefaultencoding('GB2312') #在CMD中运行编码为GB2312,在Python中应修改为UTF-8

UDP_IP = "127.0.0.1"
UDP_PORT = 9527
ip_address = (UDP_IP,UDP_PORT)


def main():
sock = socket.socket(socket.AF_INET, # Internet地址族
socket.SOCK_DGRAM) # UDP协议

print '''
欢迎来到*** %s的日记本--********
输入‘r’---载入历史记录

'''%UDP_IP
MESSAGE = raw_input("写点什么呢:") #一次只能一行内容

if MESSAGE == 'r':
print "正在打开日志……"
sock.sendto(MESSAGE,ip_address)#发送信息到服务端
print sock.recv(1024)#接受服务端回馈的信息

else:
sock.sendto(MESSAGE,ip_address)
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "已发送信息:", MESSAGE

while 1:
main()
19 changes: 19 additions & 0 deletions _src/om2py3w/3wex0/main_s.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
import socket
import sys,codecs
reload(sys)
sys.setdefaultencoding('GB2312')

UDP_IP = "127.0.0.1"
UDP_PORT = 5005

def server_con():
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print "已接收信息:", data, "来自", addr


while True:
server_con()
Loading