payload = {
"game": "csgo",
...
}
r = requests.post('xxx.com', data=payload)
account_info = api.account_info()
print(account_info['balance'] )
pg.display.set_mode((0, 0), pg.FULLSCREEN)
import pygame, os
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.init()
info = pygame.display.Info()
screen_width, screen_height = info.current_w, info.current_h
win = pygame.display.set_mode((640, 480), pygame.RESIZABLE)
window_width, window_height = screen_width, screen_height - 50
window = pygame.display.set_mode((window_width, window_height))
pygame.display.update()
import sys
import pygame
if sys.platform == "win32":
from ctypes import windll, Structure, c_long, c_ulong, sizeof, byref
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_NORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZE = 11
SW_MAX = 11
SWP_NOSIZE = 0x0001
SWP_NOMOVE = 0x0002
SWP_NOZORDER = 0x0004
SWP_NOREDRAW = 0x0008
SWP_NOACTIVATE = 0x0010
SWP_FRAMECHANGED = 0x0020
SWP_SHOWWINDOW = 0x0040
SWP_HIDEWINDOW = 0x0080
SWP_NOCOPYBITS = 0x0100
SWP_NOOWNERZORDER = 0x0200
SWP_NOSENDCHANGING = 0x0400
SWP_DRAWFRAME = SWP_FRAMECHANGED
SWP_NOREPOSITION = SWP_NOOWNERZORDER
HWND_TOP = 0
HWND_BOTTOM = 1
HWND_TOPMOST = -1
HWND_NOTOPMOST = -2
user32 = windll.user32
IsIconic = user32.IsIconic
IsZoomed = user32.IsZoomed
ShowWindow = user32.ShowWindow
GetWindowRect = user32.GetWindowRect
SetWindowPos = user32.SetWindowPos
GetForegroundWindow = user32.GetForegroundWindow
SetForegroundWindow = user32.SetForegroundWindow
class RECT(Structure):
_fields_ = [
('left', c_long),
('top', c_long),
('right', c_long),
('bottom', c_long),
]
def width(self): return self.right - self.left
def height(self): return self.bottom - self.top
def getSDLWindow():
return pygame.display.get_wm_info()['window']
def SDL_IsIconic():
return IsIconic(getSDLWindow())
def SDL_IsMaximized():
return IsZoomed(getSDLWindow())
def SDL_Minimize():
return ShowWindow(getSDLWindow(), SW_MINIMIZE)
def SDL_Maximize():
return ShowWindow(getSDLWindow(), SW_MAXIMIZE)
def SDL_Restore():
return ShowWindow(getSDLWindow(), SW_RESTORE)
def SDL_Show(state):
state = (SW_HIDE, SW_SHOW)[bool(state)]
return ShowWindow(getSDLWindow(), state)
def SDL_Activate():
hWnd = getSDLWindow()
if GetForegroundWindow() != hWnd:
SetForegroundWindow(hWnd)
def SDL_GetWindowPos():
rc = RECT()
GetWindowRect(getSDLWindow(), byref(rc))
return rc.left, rc.top
def SDL_GetWindowSize():
rc = RECT()
GetWindowRect(getSDLWindow(), byref(rc))
return rc.width(), rc.height()
def SDL_SetWindowPos(x, y):
return SetWindowPos(getSDLWindow(), 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE)
def SDL_AlwaysOnTop(state):
zorder = (HWND_NOTOPMOST, HWND_TOPMOST)[state]
return SetWindowPos(getSDLWindow(), zorder, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
else:
def SDL_IsIconic():
return 0
def SDL_IsMaximized():
return 0
def SDL_Minimize():
return 0
def SDL_Maximize():
return 0
def SDL_Restore():
return 0
def SDL_Show(state):
return 0
def SDL_Activate():
pass
def SDL_GetWindowPos():
return (-1, -1)
def SDL_SetWindowPos(x, y):
return 0
def SDL_AlwaysOnTop(state):
return 0
import pygame
import sys
from pygame.locals import QUIT
from sdl_window_utils import SDL_Maximize, SDL_GetWindowSize
pygame.init()
window_surface = pygame.display.set_mode((0, 0), pygame.RESIZABLE)
print(f'Before resize: {window_surface}')
SDL_Maximize()
w, h = SDL_GetWindowSize()
window_surface = pygame.display.set_mode((w, h))
pygame.display.update()
print(f'After resize: {window_surface}')
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Before resize: <Surface(2560x1440x32 SW)>
After resize: <Surface(2576x1416x32 SW)>
account_info = api.account_info()
balance = account_info['balance']
while True:
sleep(5)
account_info = api.account_info()
new_balance = account_info['balance']
if new_balance != balance:
balance = new_balance
print('+')
mySelectElement = browser.find_element_by_id('providerTypeDropDown')
dropDownMenu = Select(mySelectElement)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//select[@id='providerTypeDropDown']//options[contains(.,'Professional')]")))
dropDownMenu.select_by_visible_text('Professional')
params = {
'detailNum': 'F00VC17503',
'make': 'Bosch',
}
import os
from flask import Flask
from flask import send_from_directory
app = Flask(__name__)
@app.route('/<path:filename>', methods=['GET', 'POST'])
def download(filename):
uploads = os.path.join(app.root_path)
return send_from_directory(directory=uploads, filename=filename)
Python scripts (files with the extension .py) will be executed by python.exe by default. This executable opens a terminal, which stays open even if the program uses a GUI. If you do not want this to happen, use the extension .pyw which will cause the script to be executed by pythonw.exe by default (both executables are located in the top-level of your Python installation directory). This suppresses the terminal window on startup.
A limited account with one web app at your-username.pythonanywhere.com, restricted outbound Internet access from your apps, low CPU/bandwidth, no IPython/Jupyter notebook support.
It works and it's a great way to get started!
{"2000000003": {"amv": true, "amvl": true, "whoa": true}}
{"2000000004": {"amv": true, "amvl": true, "whoa": true}}
import json
target_id = '2000000004'
result = []
with open('test.json', encoding='UTF-8') as source, \
open('test_out.json', 'w', encoding='UTF-8') as out:
for line in source:
parsed_json_line = json.loads(line)
if target_id in parsed_json_line.keys():
parsed_json_line[target_id]['amv'] = False
out.write(f'{json.dumps(parsed_json_line)}\n')
import json
result = []
with open('test.json', encoding='UTF-8') as f:
for line in f:
result.append(json.loads(line))
target_id = '2000000004'
for i, item in enumerate(result):
if target_id in item.keys():
result[i][target_id]['amv'] = False
with open('test_out.json', 'w', encoding='UTF-8') as f:
for item in result:
f.write(f'{json.dumps(item)}\n')
{"2000000003": {"amv": true, "amvl": true, "whoa": true}}
{"2000000004": {"amv": false, "amvl": true, "whoa": true}}
import time
from selenium import webdriver
class Test():
def __init__(self):
self.driver = webdriver.Chrome()
def test_case(self):
self.driver.get("https://stepik.org/lesson/25969/step/12")
time.sleep(5)
textarea = self.driver.find_element_by_css_selector(".textarea")
textarea.send_keys('get()')
time.sleep(1)
submit_button = self.driver.find_element_by_css_selector(".submit-submission")
submit_button.click()
time.sleep(3)
if __name__ == '__main__':
a = Test()
a.test_case()
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
wait_time = 20 # seconds
class TestStepik(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.wait = WebDriverWait(self.driver, wait_time)
def tearDown(self):
self.driver.quit()
def test_submit_button(self):
self.driver.get("https://stepik.org/lesson/25969/step/12")
textarea = self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".textarea")))
textarea.send_keys('get()')
submit_button = self.driver.find_element_by_css_selector(".submit-submission")
submit_button.click()
self.wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".attempt-message_correct")))
if __name__ == '__main__':
unittest.main()
source = 'St\n\n\nri\nng test\n123 ... H.el.lo'
print(f'Before: {source}')
symbols_to_replace = {
'\n\n\n': ' ',
'\n': ' ',
'.': '',
}
for search, replace in symbols_to_replace.items():
source = source.replace(search, replace)
print(f'After: {source}')
Before: St
ri
ng test
123 ... H.el.lo
After: St ri ng test 123 Hello