Форум сайта python.su
openapi_client.exceptions.ApiTypeError: Invalid type for variable 'activated'. Required value type is datetime and passed type was NoneType at ['received_data'][0]['activated']
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((ipToConnect, int(PortToConnect))) sock.sendall(u'hello, world!')
from tkinter import * bomb = 100 best_score = 0 score = 0 press_return = True def start(event): global press_return global bomb global score if not press_return: pass else: bomb = 100 score = 0 label.config(text='') update_bomb() update_score() update_display() press_return = False def update_display(): global bomb global score if bomb > 50: bomb_label.config(image=normal_photo) elif 0 < bomb <= 50: bomb_label.config(image=no_photo) else: bomb_label.config(image=bang_photo) fuse_label.config(text='Fuse: ' + str(bomb)) score_label.config(text='Score: ' + str(score)) fuse_label.after(100, update_display) def update_bomb(): global bomb bomb -= 5 if is_alive(): fuse_label.after(400, update_bomb) def update_score(): global score score += 1 if is_alive(): score_label.after(3000, update_score) def click(): global bomb if is_alive(): bomb += 1 def is_alive(): global bomb global press_return if bomb <= 0: label.config(text='Bang! Bang! Bang!') press_return = True return False else: return True if best_score < score: best_score = score root = Tk() root.title('Bang Bang') root.geometry('500x550') best_score_label = Label(root, text='Best Score: '+ str(best_score), font=('Comic Sans MS', 14)) best_score_label.pack() label = Label(root, text='Press [enter] to start the game', font=('Comic Sans MS', 12)) label.pack() fuse_label = Label(root, text='Fuse: ' + str(bomb), font=('Comic Sans MS', 14)) fuse_label.pack() score_label = Label(root, text='Score: ' + str(score), font=('Comic Sans MS', 14)) score_label.pack() no_photo = PhotoImage(file='img/bomb_no.gif') normal_photo = PhotoImage(file='img/bomb_normal.gif') bang_photo = PhotoImage(file='img/pow.gif') bomb_label = Label(root, image=normal_photo) bomb_label.pack() click_button = Button(root, text='Click me', bg='#000000', fg='#ffffff', width=15, font=('Comic Sans MS', 14),command=click) click_button.pack() root.bind('<Return>', start) root.mainloop()
count1
blit
player()
def fonar(pustota, pustota1): if event.type == pg.KEYDOWN: if event.key == pg.K_SPACE: win.blit(pustota1, (-670,0)) if event.type == pg.KEYUP: if event.key == pg.K_SPACE: win.blit(pustota, (-670,0)) def player(pustota, xm, count1): win.blit(screen, (0, 0)) if xm <= 200: screen.blit(pustota, (count1+1, 0)) print(count1) import pygame as pg pg.init() win = pg.display.set_mode((1300, 600)) sc = pg.display.set_mode((1300, 600)) screen = pg.Surface((1300, 600)) #icon = pg.image.load('C:\Distr\python\Five-nights-at-Snusiks\Images\icon.png') pustota = pg.image.load('C:\Distr\python\Five-nights-at-Snusiks\Images\pustota.png') pustota1 = pg.image.load('C:\Distr\python\Five-nights-at-Snusiks\Images\pustota1.png') pg.display.set_caption("Fnas") run = True b1 = True f1 = pg.font.Font(None, 25) #pg.display.set_icon(icon) keys = pg.key.get_pressed() clock = pg.time.Clock() pg.display.update() count1 = -670 while run: clock.tick(60) for event in pg.event.get(): if event.type == pg.QUIT: run = False fonar(pustota, pustota1) xm, ym = pg.mouse.get_pos() text1 = f1.render(f'Mouse position: {xm} {ym}', 1, (0,0,0)) player(pustota, xm, count1) if event.type == pg.KEYDOWN: if event.key == pg.K_g: b1 = False if event.key == pg.K_h: b1 = True if b1 == False: win.blit(text1, (5,5)) print(count1) pg.display.update() pg.quit()
#!/usr/bin/env python import struct import time import PySimpleGUI as sg import matplotlib.pyplot as plt # $ pip install matplotlib import matplotlib.animation as animation from collections import deque from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from socket import * def draw_figure(canvas, figure): figure_canvas_agg = FigureCanvasTkAgg(figure, canvas) figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1) figure_canvas_agg.draw() return figure_canvas_agg def delete_fig_agg(fig_agg): fig_agg.get_tk_widget().forget() plt.close('all') def new_subplot(y,x,n,fig): ax = fig.add_subplot(y, x, n) ax.set_autoscale_on(True) plt.ylabel('HC#'+ str(n)) plt.xlabel('time, sec') plt.xticks() plt.yticks() plt.grid() ax.grid(linestyle="-", which='major', linewidth=0.5, color='.25', zorder=-10) ax.grid(linestyle="-", which='minor', linewidth=0.25, color='.75', zorder=-10) return ax def update_animation(i, cur_time, x, y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12): #data1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] data_flag = False while 1: try: data, addr = udp_socket.recvfrom(1024) data1 = struct.unpack("fffffffffffff", data) data_flag = True except Exception: break timing_ = time.time()-cur_time x.append(timing_) if data_flag: y1.append(data1[3]) y2.append(data1[4]) y3.append(data1[5]) y4.append(data1[6]) y5.append(data1[7]) y6.append(data1[8]) y7.append(data1[9]) y8.append(data1[10]) y9.append(data1[11]) y10.append(data1[12]) y11.append(data1[3]) y12.append(data1[4]) else: y1.append(y1[npoints - 1]) y2.append(y2[npoints - 1]) y3.append(y3[npoints - 1]) y4.append(y4[npoints - 1]) y5.append(y5[npoints - 1]) y6.append(y6[npoints - 1]) y7.append(y7[npoints - 1]) y8.append(y8[npoints - 1]) y9.append(y9[npoints - 1]) y10.append(y10[npoints - 1]) y11.append(y11[npoints - 1]) y12.append(y12[npoints - 1]) line1.set_data(x, y1) line2.set_data(x, y2) line3.set_data(x, y3) line4.set_data(x, y4) line5.set_data(x, y5) line6.set_data(x, y6) line7.set_data(x, y7) line8.set_data(x, y8) line9.set_data(x, y9) line10.set_data(x, y10) line11.set_data(x, y11) line12.set_data(x, y12) ax1.set_ylim(-1.1, 1.1) ax1.set_xlim(x[npoints-1]-40.5, x[npoints-1]+0.5) ax2.set_ylim(-1.1, 1.1) ax2.set_xlim(x[npoints-1]-40.5, x[npoints-1]+0.5) ax3.set_ylim(-1.1, 1.1) ax3.set_xlim(x[npoints-1]-40.5, x[npoints-1]+0.5) ax4.set_ylim(-1.1, 1.1) ax4.set_xlim(x[npoints-1]-40.5, x[npoints-1]+0.5) ax5.set_ylim(-1.1, 1.1) ax5.set_xlim(x[npoints-1]-40.5, x[npoints-1]+0.5) ax6.set_ylim(-1.1, 1.1) ax6.set_xlim(x[npoints-1]-40.5, x[npoints-1]+0.5) return line1, line2, line3, line4, line5, line6, line7, line8, line9, line10, line11, line12, ax1, ax2, ax3, ax4, ax5, ax6 host = '192.168.0.44' port = 5051 addr = (host, port) udp_socket = socket(AF_INET, SOCK_DGRAM) udp_socket.setblocking(False) udp_socket.bind(addr) npoints = 1000 x = deque([0.0], maxlen=npoints) y1 = deque([0.0], maxlen=npoints) y2 = deque([0.0], maxlen=npoints) y3 = deque([0.0], maxlen=npoints) y4 = deque([0.0], maxlen=npoints) y5 = deque([0.0], maxlen=npoints) y6 = deque([0.0], maxlen=npoints) y7 = deque([0.0], maxlen=npoints) y8 = deque([0.0], maxlen=npoints) y9 = deque([0.0], maxlen=npoints) y10 = deque([0.0], maxlen=npoints) y11 = deque([0.0], maxlen=npoints) y12 = deque([0.0], maxlen=npoints) for num in range(npoints): x.append(0.0) y1.append(0) y2.append(0) y3.append(0) y4.append(0) y5.append(0) y6.append(0) y7.append(0) y8.append(0) y9.append(0) y10.append(0) y11.append(0) y12.append(0) layout = [ [sg.Button('ГНС', enable_events=True, key='-B1-', font='Helvetica 16', size=(15, 1)), sg.Button('Слив', enable_events=True, key='-B2-', font='Helvetica 16', size=(15, 1)), sg.Button('Разот', enable_events=True, key='-B3-', font='Helvetica 16', size=(15, 1)), sg.Button('Ргсп', enable_events=True, key='-B4-', font='Helvetica 16', size=(15, 1)), sg.Button('Рслив', enable_events=True, key='-B5-', font='Helvetica 16', size=(15, 1)), sg.Button('t масла', enable_events=True, key='-B6-', font='Helvetica 16', size=(15, 1)), sg.Button('Рнагн', enable_events=True, key='-B7-', font='Helvetica 16', size=(15, 1))], [sg.Button('Авар. откл.', enable_events=True, key='-B8-', font='Helvetica 16', size=(15, 1)), sg.Button('Откр. ограждение', enable_events=True, key='-B9-', font='Helvetica 16', size=(15, 1)), sg.Button('Откр. дверь каб.', enable_events=True, key='-B10-', font='Helvetica 16', size=(15, 1)), sg.Button('Ремни', enable_events=True, key='-B11-', font='Helvetica 16', size=(15, 1)), sg.Button('Трап отведен', enable_events=True, key='-B12-', font='Helvetica 16', size=(15, 1)), sg.Button('Трап подведен', enable_events=True, key='-B13-', font='Helvetica 16', size=(15, 1)), sg.Button('СП готова', enable_events=True, key='-B14-', font='Helvetica 16', size=(15, 1))], [sg.Canvas(size=(4, 3), key='-CANVAS-', pad=(40, 30))], [sg.Button('Exit', font='Helvetica 16', size=(10, 1))], ] window = sg.Window('State Display', layout, size=(1920, 1280), finalize=True) plt.ioff() plt.figure(figsize=(18, 8), dpi=100) fig1 = plt.gcf() figure_x, figure_y, figure_w, figure_h = fig1.bbox.bounds canvas_elem = window['-CANVAS-'].TKCanvas canvas_elem.Size = (int(figure_w), int(figure_h)) ax1 = new_subplot(3, 2, 1, fig1) ax2 = new_subplot(3, 2, 3, fig1) ax3 = new_subplot(3, 2, 5, fig1) ax4 = new_subplot(3, 2, 2, fig1) ax5 = new_subplot(3, 2, 4, fig1) ax6 = new_subplot(3, 2, 6, fig1) fig1.subplots_adjust(hspace=0.3) fig1.suptitle('Current HC state', fontsize=16) plt.tight_layout() [line1] = ax1.plot(x, y1, 'b') [line2] = ax1.plot(x, y2, 'r') [line3] = ax2.plot(x, y3, 'b') [line4] = ax2.plot(x, y4, 'r') [line5] = ax3.plot(x, y5, 'b') [line6] = ax3.plot(x, y6, 'r') [line7] = ax4.plot(x, y7, 'b') [line8] = ax4.plot(x, y8, 'r') [line9] = ax5.plot(x, y9, 'b') [line10] = ax5.plot(x, y10, 'r') [line11] = ax6.plot(x, y11, 'b') [line12] = ax6.plot(x, y12, 'r') timing = time.time() ani = animation.FuncAnimation(fig1, update_animation, fargs=(timing, x, y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12), interval=10) fig_agg = draw_figure(canvas_elem, fig1) plt.show() udp_socket.close()
import requests import fake_useragent user = fake_useragent.UserAgent().random session = requests.session() file = open('test.jpg', 'rb') link = 'https://www.site.com/media/uploadphoto' header = { 'user-agent': user, 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryHsR5BRK1nhWRjcPL', } data = { 'verified': '0', 'fileUpload': ?????, 'anonymous': 'on', 'title': 'text', 'description': 'text2', } session.post(link,???
rax = plt.axes ([0.905, 0.545, 0.09, 0.45], facecolor='yellow') radio = RadioButtons(rax, ('SBX', 'SBIX', 'DCPKU1', 'DCPKU2', 'SSKPT', 'SSKHA', 'SOC', 'SOO1', 'SOCU','DCK', 'PUPK', 'SOP1.1', 'SOU', 'SOFU1', 'SOFU2', 'SOFU3', 'SOFU4', 'SOFU5','DCR', 'DCZ2','DCZ1', 'SOP1', 'SSKU', 'SOF', 'SBXM', 'CTO'))
import requests from bs4 import BeautifulSoup import pandas as pd url = 'https://www.skyscanner.ru/transport/flights/mosc/znz/?adults=1&adultsv2=1&cabinclass=economy&children=0&childrenv2=&destinationentityid=39828399&inboundaltsenabled=false&infants=0&originentityid=27539438&outboundaltsenabled=false&preferdirects=false&preferflexible=false&ref=home&rtn=1&oym=2110&selectedoday=01&iym=2110&selectediday=01' # url страницы r = requests.get(url) with open('2.txt', 'w') as output_file: output_file.write(r.text)
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="./manifest.json"><link rel="shortcut icon" href="./favicon.ico"><title>Skyscanner</title><link rel="icon" href="/favicon.ico"><script type="text/javascript">window.__pageLoadedTime=Date.now()</script><link href="./static/css/main.83f6a466.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="./static/js/main.768c00c0.js"></script></body></html>
from netfilterqueue import NetfilterQueue def print_and_accept(pkt): print(pkt) pkt.accept() nfqueue = NetfilterQueue() nfqueue.bind(1, print_and_accept) try: nfqueue.run() except KeyboardInterrupt: print('') nfqueue.unbind()