python 20170315
来源:互联网 发布:js 技术大牛 阿里 编辑:程序博客网 时间:2024/05/22 14:34
跟着廖老师学python 20170315
#!/usr/bin/env python# -*- coding: utf-8 -*-#---GUI---ATEMPT'''from tkinter import *import tkinter.messagebox as messageboxclass Application(Frame): def __init__(self, master = None): Frame.__init__(self, master) self.pack() self.createWidgets() def createWidgets(self): self.helloLabel = Label(self, text = 'Hello, world!') self.helloLabel.pack() self.quitButton = Button(self, text = 'Quit', command = self.quit) self.quitButton.pack() self.alertButton = Button(self, text = 'Click me', command = self.hello) self.alertButton.pack() self.nameInput = Entry(self) self.nameInput.pack() def hello(self): name = self.nameInput.get() or 'world' messagebox.showinfo('Message', 'Hello, %s ' % name)app = Application()app.master.title('Hello world 对话框标题')app.mainloop()'''#---pro---day2---lack of module aiohttp'''import logging; logging.basicConfig(level=logging.INFO)import asyncio, os, json, timefrom datetime import datetimefrom aiohttp import webdef index(request): return web.Response(body=b'<h1>Awesome</h1>')@asyncio.coroutinedef init(loop): app = web.Application(loop=loop) app.router.add_route('GET', '/', index) srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000) logging.info('server started at http://127.0.0.1:9000...') return srvloop = asyncio.get_event_loop()loop.run_until_complete(init(loop))loop.run_forever()'''#---partial function---base---'''def int2to10 (x,base=2): return int(x,base)a=int2to10('1000')print(a)'''#---module---''''a test module'_author_ = 'ziboris'import sysdef test1(): args=sys.argv if len(args)==1: print('hello world!') elif len(args)==2: print ('hello %s!' %args[1]) else: print('too many arguments!')test1()'''#---private---'''def _private_1(name): return 'hello,%s' %namedef _private_2(name): return 'hi,%s' %namedef greeting(name): if(len(name)>3): return _private_1(name) else: return _private_2(name)greeting('ziboris')print('--')a=_private_1('ziboris')print(a)'''#---self---'''class student(object): def _init_(self,stuname,score): self._stuname=stuname self._score=score def print_score(self): print('%s:%s' %(self._stuname,self._score))stu=student('ziboris',100)stu.print_score()''''''class Myclass(): def func(self,a): print ('func :',a)p=Myclass()p.func('hello')'''
1 0
- python 20170315
- Python
- Python
- Python
- python
- Python
- PYTHON
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- python
- android intent传递数据
- vue-cli构建vue项目
- [Updating] Codeforces Round #404 (Div. 2) 解题报告
- C++Primer第五版 第十六章习题答案(31~40)
- hibernate 中的通用接口BaseDao 和BaseDaoImpl的制作 ,泛型制作
- python 20170315
- 再谈Mybatis之Association Collection
- Pruffer
- 网易视频云海外加速方案发布啦!
- ios客户端学习-二维码扫描和应用跳转
- 《图解HTTP[上野宣]》读书笔记二
- aws 噼里啪啦做了一天测试 花了4$
- iOS-申请邓白氏编码的超详细流程介绍
- Qt WebEngine无法启动