Архивы автора: 1 1

Python pyodbc postgres

import pyodbc
conn_str = (
    "DRIVER={PostgreSQL Unicode};"
    "DATABASE=postgres;"
    "UID=postgres;"
    "PWD=whatever;"
    "SERVER=localhost;"
    "PORT=5432;"
    )
conn = pyodbc.connect(conn_str)
crsr = conn.execute("SELECT 123 AS n")
row = crsr.fetchone()
print(row)
crsr.close()
conn.close()

колёсико мышки в pygame

import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640, 480))
clock = pygame.time.Clock()
def main():
   while True:
      for event in pygame.event.get():
            if event.type == QUIT:
               pygame.quit()
               return
            elif event.type == MOUSEWHEEL:
               print(event)
               print(event.x, event.y)
               print(event.flipped)
               print(event.which)
      clock.tick(60)
main()

Подключение .NET в программу на Python

Python .NET
PS C:\Users\user> C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe  -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pythonnet
Collecting pythonnet
  Downloading pythonnet-2.5.2-cp38-cp38-win_amd64.whl (81 kB)
     |████████████████████████████████| 81 kB 39 kB/s
Requirement already satisfied: pycparser in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from pythonnet) (2.20)
Installing collected packages: pythonnet
Successfully installed pythonnet-2.5.2
PS C:\Users\user> C:\Users\user\AppData\Local\Programs\Python\Python38\python.exe
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> from System import String

>>> from System import Math
>>> Math.Round(1.2346, 3)
1.235
>>>

Написание и компиляция программы на C# без инструментов

Код файла с программой:

using System;
class test {
	static void Main(){
		Console.Write("Enter Path:");
		var path = Console.ReadLine();
		var file = new System.IO.StreamWriter(path, true);
		var OutText = "test some text";
		file.WriteLine(OutText);
		file.Close();
	}
}

Компиляция:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe .\1.cs

В результате в текущей папке сформируется экзешник