import datetime
TIME_START = datetime.datetime.now()
...
plt_target_dir += TIME_START.strftime(
"%Y.%m.%d_%H.%M"
)
Python добавление текущей даты и времени к имени файла или папки
Добавить комментарий
import datetime
TIME_START = datetime.datetime.now()
...
plt_target_dir += TIME_START.strftime(
"%Y.%m.%d_%H.%M"
)
sudo apt install gcc
sudo apt install g++a
user@comp:~/test/cpp$ g++ test.cpp
user@comp:~/test/cpp$ ls
a.out test.cpp
user@comp:~/test/cpp$ ./a.out
test message
user@comp:~/test/cpp$
>>> import pyodbc
>>> pyodbc.drivers()
['SQL Server', 'Microsoft Access Driver (*.mdb, *.accdb)', 'Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)', 'Microsoft Access Text Driver (*.txt, *.csv)', 'SQL Server Native Client 11.0', 'ODBC Driver 17 for SQL Server', 'SQL Server Native Client RDA 11.0', 'PostgreSQL ANSI(x64)', 'PostgreSQL Unicode(x64)', 'PostgreSQL ANSI', 'PostgreSQL Unicode']
>>>
https://ftp.postgresql.org/pub/odbc/versions/msi/psqlodbc_13_01_0000-x64.zip
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()
>>> help(ord)
Help on built-in function ord in module builtins:
ord(c, /)
Return the Unicode code point for a one-character string.
>>> ord('2')
50
>>> ord('п')
1087
>>> chr(50)
'2'
>>> chr(1087)
'п'
>>>
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()
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
>>>
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Module docstring
"""
import ...
Ещё варианты обсуждают здесь https://stackoverflow.com/questions/1523427/what-is-the-common-header-format-of-python-files
dir > a.txt 2>&1
Синтаксис 2>&1 перенаправит 2 (stderr) в 1 (stdout).