Пример #1
0
def index(request):
    Hello.hi()
    context_dict = {
        'title': "Home",
        'msg': "Andy's Django Project",
        'img': "bulbasaur.jpg"
    }
    return render(request, 'index.html', context_dict)
Пример #2
0
 def __init__(self,MyMacAdd,ID):
     self.myMACadd=MyMacAdd
     self.broadcast=b'\xff\xff\xff\xff\xff\xff'
     self.protocol=b'\x08\x01'
     self.payload=''
     self.Type_message={
     'Hello':'0',
     'MPR_message':'1',
     'Message':'2'
     }
     self.tp=Topology(ID)
     self.msj_out=''
     self.message_Hello=Hello(ID)
     self.message_MPR=MPRmsj(ID)
     self.message=Message(ID)
     self.temperature=0
Пример #3
0
class Packed(Hello,MPRmsj,Message,Topology):
    def __init__(self,MyMacAdd,ID):
        self.myMACadd=MyMacAdd
        self.broadcast=b'\xff\xff\xff\xff\xff\xff'
        self.protocol=b'\x08\x01'
        self.payload=''
        self.Type_message={
        'Hello':'0',
        'MPR_message':'1',
        'Message':'2'
        }
        self.tp=Topology(ID)
        self.msj_out=''
        self.message_Hello=Hello(ID)
        self.message_MPR=MPRmsj(ID)
        self.message=Message(ID)
        self.temperature=0

    def Pack(self,type,IDdst,**temp):
        self.msj_out=self.broadcast+self.myMACadd+self.protocol
        self.temperature=temp
        if type==self.Type_message['Hello']:
            self.payload=self.message_Hello.Hello_pack(self.tp)
        elif type==self.Type_message['MPR_message']:
            self.payload=self.message_MPR.MPRmsj_pack(self.tp)
        elif type==Type_message['Message']:
            self.payload=self.message.Message_pack(IDdst,self.temperature)
        else:
            print('Error, invalid type of message...')
        self.msj_out+=self.payload
        return self.msj_out

    def Unpack(self,msj):
        payload=msj[14:]
        type=payload[0:1].decode('utf-8')
        if type==self.Type_message['Hello']:
            self.message_Hello.Hello_unpack(payload,self.tp)
        elif type==self.Type_message['MPR_message']:
            self.message_MPR.MPRmsj_unpack(payload,self.tp)
        elif type==self.Type_message['Message']:
            self.message.Message_unpack(payload,self.tp)
        else:
            print('Error, message type incorrect...')
def reload():
    time = request.args.get('time')
    url = "https://lindia.oss-cn-beijing.aliyuncs.com/002.mp4?x-oss-process=video/snapshot,t_%s,f_jpg,w_800,h_600" % time
    # 创建新线程
    thread1 = Hello.myThread(1, url)
    thread2 = Hello.myThread(2, url)
    thread3 = Hello.myThread(3, url)
    # 开启线程
    thread1.start()
    thread2.start()
    thread3.start()
    thread1.join()
    thread2.join()
    thread3.join()
    res1 = thread1.get_result()  #车道线
    res2 = thread2.get_result()  #车辆检测
    res3 = thread3.get_result()  #交通信号灯
    result = res1 + res2 + res3
    json_data = json.dumps(result)
    #print(res1)
    print(json_data)
    return json_data
Пример #5
0
# copyright enhancedEPM

import Hello
import config

app = Hello.create_app(config)

# This is only used when running locally. When running live, gunicorn runs 
# the application. 
if __name__ == '__main__':
	app.run(host='127.0.0.1', port=8080, debug=True)

Пример #6
0
import os

if os.path.exists('./libhello.so'):
    os.rename('./libhello.so', './Hello.so')

import Hello
Hello.Print()
Hello.PrintText('this is from python')
Пример #7
0
import Hello

name = input("Enter your name: ")

Hello.greeting(name)
Пример #8
0
import Hello as H
H.Hello("Amani")

import platform

print(platform.python_version())
import Hello
import Calc
import Calc as c
from Calc import sub

Hello.SayHello('이순신')
print(Calc.add(1, 2))
print(c.add(1, 2))
print(sub(2, 1))
Пример #10
0
 def byeb(self):
     print("Bye")
     Hello().hi()
Пример #11
0
class Gender(Enum):
    Male = 0
    Female = 1


print(Gender.Male)


# type
def fn(self, name='world'):
    print('hello, %s' % name)


Hello = type('Hello', (object, ), dict(hello=fn, att='hello'))

h = Hello()
h.hello()
h.__name = 'nihao'
print(h.__name)
print(h.att)

# metaclass magic code
t_1 = []

# t_1.add('1')


# ORM + METACLASS
class Field(object):
    def __init__(self, name, column_type):
        self.name = name
Пример #12
0
import Hello
import sys


myName = sys.argv[1]
event = {'name': myName}
context = {}
result = Hello.my_handler(event, context)
print('cmd-line param name=' + myName)
print('function result:')
print(result)
Пример #13
0
import sys
sys.path.append("game/")
import Hello as h

h.sayHello()
Пример #14
0
#!/usr/bin/python
#coding:utf-8

#Moudle把类似功能的代码写在一个模块里,这样整体代码就更清楚了
#日历模块 calendar
#导入模块的目录需要跟建立的这个.py文件是同个目录下(比如都是在F:/python/)
#模块名很长,可以变简洁一些,import 模块名 as 新名字  这一形式来导入模块

import calendar
import Hello as h
print(calendar)

#直接使用木块里的函数会报错,我们需要指定函数的来源,就像不同的班级都有叫小明的人,需要说清楚是哪个班的小明
#在方法名前面加上模块名,形成【模块名.函数】的形式
#hi()
h.hi()

#如果模块中有很多函数,但是只需要用到其中一个或几个,可以用from...import...的形式
#调用函数的时候就可以不用再说明模块了
from Hello import hi
hi()

#从模块中引入所有函数,那就用from...import*(这种写法一般不推荐,程序很多时,这样写容易出错)
from Hello import *
say()

#calendar模块中又一个month的函数,调用这个含函数传入年和月两个参数,比如2019年8月
date = calendar.month(2019, 8)
print(date)

#导入一个不在同一目录下的模块--用到sys模块里的path来显示
Пример #15
0
import sys
import Hello
from PyQt5.QtWidgets import QApplication, QMainWindow

if __name__ == '__main__':
    app = QApplication(sys.argv)
    MainWindow = QMainWindow()
    ui = Hello.Ui_Hello()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
# Hello.py

def greeting(name):
    print("Hello", name)
    
# Test.py

import Hello

Hello.greeting("Python")

'''
Output:

Hello Python

'''
Пример #17
0
#question=['name','quest','favorite color']
#answer=['lancelot','the only grail','blue']
#for q,a in zip(question,answer):
#    print('what is your{0}?  it is {1}.'.format(q,a))

#for i in reversed(range(1,10,2)):
#    print (i)
#basket=['apple','orange','apple','pear','orange','banaer']
#for f in sorted(set(basket)):
#    print (f)

#import sys

#print("命令行参数如下:")
#for i in sys.argv:
#    print(i)

#print ('\n\npython 路径为:',sys.path,'\n')

#!/usr/bin/python3
# Filename: Hello.py

if __name__ == '__main__':
    print('程序自身在运行')
else:
    print('我来自其他模块')

import Hello
Hello()
Пример #18
0
def welcome():
    program = input(
        "What program do you want to use? (type '?' for a list of programs)... "
    )

    if (program == "?"):
        list = ("- Hello: Type 'hello'",
                "- Celsius/farenheit converter: Type: 'temp'",
                "- Parsec/light year converter: Type 'astro'",
                "- Sigma (sum calculator): Type: 'sigma'",
                "- Fibonnaci term finder: Type 'fibo'",
                "- Coin change # calculator: Type: 'coins'",
                "To exit, write 'exit'")

        for words in list:

            print(words)

        welcome()
    elif (program == "hello"):
        print("")
        print("-----------------------------------------------------------")
        print("")
        try:
            import Hello
            Hello.Hello()
        except:
            input(
                "Sorry, an error has been found. Press ENTER to return to the main screen"
            )
        print("")
        print("-----------------------------------------------------------")
        print("")
        welcome()
    elif (program == "temp"):
        print("")
        print("-----------------------------------------------------------")
        print("")
        try:
            import tempcon
            tempcon.convertT()
        except:
            input(
                "Sorry, an error has been found. Press ENTER to return to the main screen"
            )
        print("")
        print("-----------------------------------------------------------")
        print("")
        welcome()
    elif (program == "astro"):
        print("")
        print("-----------------------------------------------------------")
        print("")
        try:
            import astrocon
            astrocon.convertA()
        except:
            input(
                "Sorry, an error has been found. Press ENTER to return to the main screen"
            )
        print("")
        print("-----------------------------------------------------------")
        print("")
        welcome()
    elif (program == "sigma"):
        print("")
        print("-----------------------------------------------------------")
        print("")
        try:
            import Sigma
            Sigma.sigma()
        except:
            input(
                "Sorry, an error has been found. Press ENTER to return to the main screen"
            )
        print("")
        print("-----------------------------------------------------------")
        print("")
        welcome()
    elif (program == "fibo"):
        print("")
        print("-----------------------------------------------------------")
        print("")
        try:
            import Fibonnaci
            Fibonnaci.main()
        except:
            input(
                "Sorry, an error has been found. Press ENTER to return to the main screen"
            )
        print("")
        print("-----------------------------------------------------------")
        print("")
        welcome()
    elif (program == "coins"):
        print("")
        print("-----------------------------------------------------------")
        print("")
        try:
            import coins
            coins.count()
        except:
            input(
                "Sorry, an error has been found. Press ENTER to return to the main screen"
            )
        print("")
        print("-----------------------------------------------------------")
        print("")
        welcome()
    elif (program == "exit"):
        exit()
    else:
        print("Program not available, verify name")
        welcome()
Пример #19
0
def hello_handler(ws, **kwargs):
    message = Hello(message="hello, world!")
    while ws.open:
        yield from ws.send(Hello.dumps(message))
        yield from asyncio.sleep(1)
Пример #20
0
import Hello

Hello.hello("Bob")
Пример #21
0
def index(request):
    Hello.hi()
    context_dict = {'title': "Home", 'msg': "Andy's Django Project", 'img': "bulbasaur.jpg"}
    return render(request, 'index.html', context_dict)
Пример #22
0
# 模块  模块是一组python代码的集合  一个.py 文件就是一个模块
# 好处
# 提高代码的可维护性
# 相互调用
# package

import Hello
print(Hello.greeting('nico'))
print(Hello.greeting('rui'))
print(Hello.__private_1('rui'))
Пример #23
0
import sys
import Hello
# 该方法可以调用UIDensigner中的MainWindow
from PyQt5.QtWidgets import QApplication, QMainWindow

if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindow = QMainWindow()
    ui = Hello.Ui_MainWindow()
    # 向主窗口上添加控件
    ui.setupUi(mainWindow)
    mainWindow.show()
    sys.exit(app.exec_())
Пример #24
0
#test.py模块代码,导入Hello模块
import Hello

#调用Hello模块中的函数
Hello.printInfo()
Hello.printSum(12, 13)
Пример #25
0
import sys
import Hello
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
Myapp = Hello.Ui_MainWindow()

sys.exit(app.exec())
Пример #26
0

def btnCopy_Click(p1):
    txtCopyVar.set(txtHlaskaVar.get())


def btnPozdrav_Click(p1):
    # print('Hello_support.btnPozdrav_Click')
    # print('p1 = {0}'.format(p1))
    # sys.stdout.flush()
    txtHlaskaVar.set("Hello World")  # naplneni textoveho pole


def init(top, gui, *args, **kwargs):
    global w, top_level, root
    w = gui
    top_level = top
    root = top


def destroy_window():
    # Function which closes the window.
    global top_level
    top_level.destroy()
    top_level = None


if __name__ == '__main__':
    import Hello
    Hello.vp_start_gui()
def main():
    # APP CODE
    app = Hello.Hello()
    print app.hello_world()
Пример #28
0
import time as t  # from time import* 也可寫成這樣

print(t.localtime())
print(t.time())

 ## import Hello function

import Hello

Hello.hello('I am Hello')
Пример #29
0
# -*- coding: UTF-8 -*-
import Hello
import os

a = Hello.fun1(10, 20, 30)
print a

# print input('please input: ')
try:
    string = open('test.txt', "r")
    print string.name
except IOError, e:
    print e
else:
    print "异常出现"

a = 10
print a
Пример #30
0
#在python中一个.py文件就是一个模块。使用模块能够提高代码的可维护性,便于代码的重用,还能够避免
#命名冲突,需要注意不要与保留字以及内置函数命名冲突。为了避免模块名冲突,python引入了packeage。
#package是按文件目录组织模块的,文件目录中必须存在一个__init__.py文件,这个文件的模块名为package

#如何使用模块?
#在一个模块中,可以定义很多的函数和变量,但有的函数和变量我们希望是public,部分函数和变量是private
#在python中是通过_前缀来实现的,正常的函数和变量都是public可以被直接引用,类似于__xxx__这样的变量
#是特殊变量,可以直接被引用,但是有特殊用途,一般我们的变量名不要使用这种方式定义。类似于_x或者__xxx
#这样的变量和函数是private的‘不应该’被外部直接引用。python并没有一种方法约束外部模块访问private函数和变量

#在python中安装第三方模块是通过pip包管理工具完成的。
#python3对应的pip3,python2则对应于pip,一般第三方库都会在pypi.python.org网站注册
#安装模块命令:pip install '模块名'

#模块搜索路径
#当我们试图加载一个模块时,python会在指定的路径下搜索对应的py文件,如果找不到则报错
#默认情况下,python解释器会搜索当前目录、所有已安装的内置模块和第三方模块,搜索路径
#存放在sys模块的path变量中
import sys

print(sys.path)

#如果需要添加自定义的搜索目录有两种办法:
#1. sys.path.append('path'),运行时生效,运行结束后失效
#2. 在python的环境变量PYTHONPATH中,该环境变量的内容会被自动添加到模块搜索路径中

#使用自定义的模块
import Hello

Hello.test()