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

advanced_classification | 广阔天地,大有作为 #13

Open
laiqun opened this issue Feb 27, 2018 · 10 comments
Open

advanced_classification | 广阔天地,大有作为 #13

laiqun opened this issue Feb 27, 2018 · 10 comments

Comments

@laiqun
Copy link
Owner

laiqun commented Feb 27, 2018

https://laiqun.github.io/2018/02/26/advanced-classification/#more

@laiqun
Copy link
Owner Author

laiqun commented Nov 7, 2018

https://stackoverflow.com/questions/12832891/django-postman-extends-a-base-html-that-does-not-exist
login_required 默认会跳转到‘/accounts/login/’。这个值可以在settings文件中通过LOGIN_URL参数来设定。

@laiqun
Copy link
Owner Author

laiqun commented Jan 21, 2019

find . -type f -print0 | xargs -0 grep "META_SetIpComPortMap"

@laiqun
Copy link
Owner Author

laiqun commented Jan 24, 2019

通过资源管理器打开某个指定的文件夹
import os
os.startfile("c:\")
播放音乐文件
import winsound

@laiqun
Copy link
Owner Author

laiqun commented Feb 25, 2019

cocos creator处理UUID的代码

function xx(t) {
var n = JSON.parse("[64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,62,64,64,64,63,52,53,54,55,56,57,58,59,60,61,64,64,64,64,64,64,64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,64,64,64,64,64,64,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]");
var r = JSON.parse("[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"]");
var o = JSON.parse("[\"a\",\"a\",\"0\",\"8\",\"f\",\"5\",\"d\",\"f\",\"-\",\"9\",\"0\",\"7\",\"d\",\"-\",\"4\",\"4\",\"a\",\"9\",\"-\",\"9\",\"5\",\"0\",\"2\",\"-\",\"c\",\"a\",\"0\",\"7\",\"1\",\"1\",\"2\",\"f\",\"c\",\"e\",\"a\",\"d\"]");
var a = JSON.parse("[0,1,2,3,4,5,6,7,9,10,11,12,14,15,16,17,19,20,21,22,24,25,26,27,28,29,30,31,32,33,34,35]");
                    if (22 !== t.length) return t;
                    o[0] = t[0],
                    o[1] = t[1];
                    for (var e = 2, i = 2; e < 22; e += 2) {
                      var s = n[t.charCodeAt(e)],
                      c = n[t.charCodeAt(e + 1)];
                      o[a[i++]] = r[s >> 2],
                      o[a[i++]] = r[(3 & s) << 2 | c >> 4],
                      o[a[i++]] = r[15 & c]
                    }
                    return o.join('')
                  }

根据json找到对应的资源

@laiqun
Copy link
Owner Author

laiqun commented Mar 5, 2019

#文件读写
文件读写的重要性,unix/linux是完全基于文件的,设备也是基于文件,从设备读就是读文件,写入设备就是写文件,你就可以得知文件的重要性了。

学习python应该是怎样的学习流程?
首先看《python简明教程》,这本书可以在2小时内读完,你会对python的基本语法有所了解。
然后看廖雪峰的《python教程》,这边讲的比较通俗,可以学一些扩展模块的使用。
看完这些之后,我们要根据您具体的用途来学习,有以下几种方向:

  1. 数据和文件处理 处理文本文件和数据文件 ,这个问题,如果不复杂的话,可以使用find 正则表达式等实现。
    处理二进制数据可以使用struct这个模块
import struct#有点像sscanf,格式化字符串,这里是格式化字节   
#struct.pack('>I', 10240099)  将10240099转换成大端  无符号字节
#struct.unpack('<ccIIIIIIHH', s)  # s = b'\x42\x4d\x38\x8c\x0a\x00\x00\x00\x00\x00\x36\x00\x00\x00\x28\x00\x00\x00\x80\x02\x00\x00\x68\x01\x00\x00\x01\x00\x18\x00'
#将s执行的字节数组,转换为小端   字符、字符、无符号整型、无符号整型、 …… 双字节无符号整型
  1. 机器学习、数据分析、数据仓库: 这个可以看《集体智慧编程》《python 神经网络》《spark快速大数据处理》等等
  2. web开发 你要建立一个网站,商城、社交网站等等,需要学习一个web框架,django flask等等。参考书籍《The django book》
  3. 桌面程序开发 为了方便,可以使用Tkinter ,参考书籍是《Python GUI Programming Cookbook》,这本书完全是案例式循序渐进学习的,可以很快的读完,要求是有一定的英文功底。
  4. 爬虫
  5. windows 操作 脚本,完成一些自动化作业;写上网认证的脚本等等
  6. 游戏(较少用) 最初的cocos 游戏框架用的是python写的,后来iphone出现,cocos框架用c#重写了,现在流行的是js来写跨平台的游戏了。

@laiqun
Copy link
Owner Author

laiqun commented Mar 21, 2019

看到同事的电脑上,每半小时都会有提醒“可以输入半小时的工作内容了”,看得出他是一个比较注重时间管理的人,我们也来做一个玩玩。
首先我们实现半小时弹窗一次的功能:

import threading
global timer 
def hello():
    messagebox.showinfo("提醒","是时候填写半小时的内容了")
    global timer
    timer = threading.Timer(30*60,hello)#30分钟后执行
    timer.start()
timer = threading.Timer(1,hello)#1s后执行
timer.start()

我们创建界面的代码:
完善界面代码的事件处理
完整代码:

#coding=utf-8 
import time
import os
import threading
from tkinter import *
from tkinter import messagebox
global timer 
global B1
global MessageTime
def hello():
    messagebox.showinfo("提醒","是时候填写半小时的内容了")
    global MessageTime
    MessageTime= time.time()
    global timer
    timer = threading.Timer(30*60,hello)
    timer.start()
    

def submit():#按钮只是messbox弹窗后的3mins 内有效,如果距离上次弹窗超过1min,则无效
    global MessageTime
    if(time.time()-MessageTime>3*60):
        messagebox.showwarning("提醒","距离可以记录的时间,已经超过了3分钟,不能记录")
        #B1.configure(state=DISABLED)
        return
    #else:
    #    B1.configure(state=NORMAL)
    if not content.get():
        messagebox.showerror("错误","输入为空")
        return

    #print(time.strftime('%Y_%m_%d',time.localtime(time.time())))
    if os.path.exists('D:\\diary'):
        pass
    else:
        os.makedirs("D:\\diary")

    
    file = open('D:\\diary'+'\\'+time.strftime('%Y_%m_%d',time.localtime(time.time()))+".txt",'a')    
    
    string = time.strftime("%I:%M",time.localtime(time.time()))+"——"+content.get()+"\n"## 12小时格式
    file.write(string)
    file.close()

    E1.delete(0,END)
    E1.focus()


timer = threading.Timer(1,hello)
timer.start()
root = Tk()
root.wm_attributes('-topmost',1)
root.title("半小时记录")
L1 = Label(root,text="请输入这半小时干了什么: ")
#L1.pack(side=LEFT)
L1.grid(row=0,column=0)
content = StringVar()
E1 = Entry(root,bd=5,width=56,textvariable=content)
#E1.pack(side = LEFT)
E1.grid(row=0,column=1)
E1.focus()
B1 = Button(root,text="提交",command = submit)

#B1.pack(side=RIGHT)
B1.grid(row=0,column=2)
#L2 = Label(root,text="任务列表: ")
#L2.grid(row=1,column=0,sticky='W')

root.mainloop()

@laiqun
Copy link
Owner Author

laiqun commented Mar 22, 2019

#coding=utf-8 
import time
import os
import threading
from tkinter import *
from tkinter import messagebox
global timer 
global MessageTime
global accumlateTime
import functools
global L1,E1,B1,L2,B2,B3,content,T1
'''
def just_one_instance(func):
    @functools.wraps(func)
    def f(*args,**kwargs):
        import socket
        try:
            global s
            s = socket.socket()
            host = socket.gethostname()
            s.bind((host,60133))
        except:
            messagebox.showwarning("提醒","已经有一个实例在运行")
            return None
        return func(*args,**kwargs)
    return f
'''
import sys
import time
import logging

logger = logging

class SingleInstance:
    def __init__(self):
        py_file_path = os.path.abspath(__file__)
        basepath = os.path.dirname(py_file_path)
        self.lockfile = os.path.normpath(basepath + '/' + os.path.basename(__file__) + '.lock')
        if sys.platform == 'win32':
            try:
                # file already exists, we try to remove (in case previous execution was interrupted)
                if os.path.exists(self.lockfile):
                    os.unlink(self.lockfile)

                self.fd = os.open(self.lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR)
            except OSError as e:
                if e.errno == 13:
                    logger.error("Another instance is already running, quit.")
                    sys.exit(-1)
                raise e
        else:
            # non Windows
            import fcntl

            self.fp = open(self.lockfile, 'w')
            try:
                fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
            except IOError:
                logger.error("Another instance is already running, quit.")
                sys.exit(-1)



accumlateTime = 30
def hello():
    global L1
    global accumlateTime,B1
    accumlateTime=accumlateTime+1  #一分钟更新一次计数
    if accumlateTime >30: #超过30分钟,可以记录了
        accumlateTime = 0
        messagebox.showinfo("提醒","是时候填写半小时的内容了")
        global MessageTime
        MessageTime= time.time()
        B1.configure(state=NORMAL)#每半小时,设置按钮为可用,提交后设置为不可用
    L1.configure(text="倒计时"+str(30-accumlateTime)+"分钟")
    global timer
    timer = threading.Timer(60,hello)
    timer.start()
    

def submit():#按钮只是messbox弹窗后的3mins 内有效,如果距离上次弹窗超过1min,则无效
    global MessageTime,content,B1
    #if(time.time()-MessageTime>3*60):
    #   messagebox.showwarning("提醒","距离可以记录的时间,已经超过了3分钟,不能记录")
        #B1.configure(state=DISABLED)
    #    return
    #else:
    #    B1.configure(state=NORMAL)
    if not content.get():
        messagebox.showerror("错误","输入为空")
        return

    #print(time.strftime('%Y_%m_%d',time.localtime(time.time())))
    if os.path.exists('D:\\diary'):
        pass
    else:
        os.makedirs("D:\\diary")

    
    file = open('D:\\diary'+'\\'+time.strftime('%Y_%m_%d',time.localtime(time.time()))+".txt",'a')    
    
    string = time.strftime("%I:%M",time.localtime(time.time()))+"——"+content.get()+"\n"## 12小时格式
    file.write(string)
    file.close()
    global E1
    E1.delete(0,END)
    E1.focus()
    B1.configure(state=DISABLED) #提交后按钮变灰色,因为每半小时只允许提交一次

def submittask():#按钮只是messbox弹窗后的3mins 内有效,如果距离上次弹窗超过1min,则无效
    global T1
    file = open('D:\\diary'+'\\'+time.strftime('%Y_%m_%d',time.localtime(time.time()))+"_task.txt",'w')    
    string = T1.get(0.0,'end')## 12小时格式
    file.write(string)
    file.close()


def loadtask():#按钮只是messbox弹窗后的3mins 内有效,如果距离上次弹窗超过1min,则无效
    global T1
    try:#文件可能不存在
        file = open('D:\\diary'+'\\'+time.strftime('%Y_%m_%d',time.localtime(time.time()))+"_task.txt",'r')    
        string = file.read()
        file.close()
        T1.delete('1.0','end')
        T1.insert(INSERT, string)
    except:
        pass

def openfolder():
    os.startfile("D:\\diary\\")
#@just_one_instance
def main():
    global L1,E1,B1,L2,B2,B3,content,T1
    timer = threading.Timer(1,hello)
    timer.start()
    root = Tk()
    root.resizable(False,False)
    root.wm_attributes('-topmost',1)
    root.title("每半小时记录一次(番茄工作法)")
    L1 = Label(root,bd=1,text="倒计时30分钟")
    #L1.pack(side=LEFT)
    L1.grid(row=0,column=0,sticky='W')
    content = StringVar()
    E1 = Entry(root,bd=1,width=20,textvariable=content)
    #E1.pack(side = LEFT)
    E1.grid(row=0,column=1)
    E1.focus()
    B1 = Button(root,bd=1,text="提交干了啥",command = submit)

    #B1.pack(side=RIGHT)
    B1.grid(row=0,column=2)
    L2 = Label(root,bd=1,text="任务列表: ")
    L2.grid(row=1,column=0,sticky='W')
    T1 = Text(root,height=5,width=40,bd=1)
    T1.grid(row=2,column=0,sticky='W',columnspan=3)
    B2 = Button(root,padx=3,text="提交任务",bd=1,command = submittask)

    #B1.pack(side=RIGHT)
    B2.grid(row=3,column=0,sticky='SW')
    B3 = Button(root,padx=3,text="加载任务",bd=1,command = loadtask)

    #B1.pack(side=RIGHT)
    B3.grid(row=3,column=2,sticky='SE')
    B4 = Button(root, padx=3, text="打开工作目录", bd=1, command=openfolder)
    B4.grid(row=3, column=1)
    root.mainloop()

if __name__ == '__main__':
    instance = SingleInstance()
    main()

@laiqun
Copy link
Owner Author

laiqun commented Apr 25, 2019

http://www.coolketang.com/hdjc/hdjc/pscc_m1/?rs=pscc_m1_l1_3&sw=1024&pc=23&nt=Photoshop%u9009%u9879%u5361%u6807%u7B7E%u7684%u4F7F%u7528&ct=%u4E92%u52A8%u6559%u7A0B%u7B2C%u4E00%u8282%uFF1A%u64CD%u4F5C%u793A%u8303
修改课程: pscc_m1中pscc_m2可以播放第二小节的
pscc_m1_l1_3 改成 pscc_m3_l3_3 可以播放第三小节,第三课的,以此类推

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant