Zu Python unter Windows (Zu Python unter Windows), Lektion, Seite 724097
https://www.purl.org/stefan_ram/pub/windows_python (Permalink) ist die kanonische URI dieser Seite.
Stefan Ram
Python-Kurs

Zu Python  unter Windows 

Zum Zugriff via com siehe auch:
>724241 Installation von Bibliotheken und Bibliotheken für Python 
UTF-8-Ausgabe auf die Konsole
__import__( "sys" ).stdout.buffer.write( chr( 0x231E ).encode( 'utf-8' ))
main.py

import os

with open( 'tmp.cmd', 'w' ) as file:

print \

( \

# program

r'ECHO '

# example

r'EXAMPLE '

, file=file, flush=True )

print( 'PAUSE', file=file, flush=True )

os.system("C:\Windows\System32\cmd.exe /k tmp.cmd")

input()

Ausführbare Datei
C:\Users\Hans\AppData\Local\Programs\Python\Python37\python.exe
Arbeitsordner
C:\Users\Hans\AppData\Local\Programs\Python\Python37\example.py
lokaler Ordner
C:\Users\Hans\AppData\Roaming\Python\Python37\site-packages\usercustomize.py
Registrierungsauszug

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.py]

@="Python.File"

"Content Type"="text/plain"

Registrierungsauszug

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File]

@="Python File"

[HKEY_CLASSES_ROOT\Python.File\DefaultIcon]

@="\"C:\\Windows\\py.exe\",1"

[HKEY_CLASSES_ROOT\Python.File\Shell]

[HKEY_CLASSES_ROOT\Python.File\Shell\open]

[HKEY_CLASSES_ROOT\Python.File\Shell\open\command]

@="\"C:\\Windows\\py.exe\" \"%L\" %*"

[HKEY_CLASSES_ROOT\Python.File\Shell\Edit with IDLE]

[HKEY_CLASSES_ROOT\Python.File\Shell\Edit with IDLE\command]

@="\"C:\\Users\\s\\AppData\\Local\\Programs\\Python\\Python37\\pythonw.exe\" -m idlelib \"%L\" %*"

Appdata

import pythoncom

from win32com.shell import shell

kfmgr = pythoncom.CoCreateInstance(

shell.CLSID_KnownFolderManager, None,

pythoncom.CLSCTX_INPROC_SERVER,

shell.IID_IKnownFolderManager)

appdata = kfmgr.GetFolder(shell.FOLDERID_RoamingAppData)

appdata_path = appdata.GetPath()

IKnownFolderManager interface:

https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iknownfoldermanager

IKnownFolder interface:

https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iknownfolder

main.py

import win32com.client

from time import sleep

xl = win32com.client.Dispatch("Excel.Application")

xl.Visible = True

sleep( 1 )

Unterprozesse

subprocess.Popen(['start', 'hello.txt'], shell=True)

subprocess.check_call( [ sys.executable, 'hello.py'])

Exe (geht nicht mit 3.8?)

pip install pyinstaller

Scripts/pyinstaller -–onefile -–windowed --icon="images\myicon.ico" myApp.py

.exe now is in dist

https://nsis.sourceforge.io/Download

create zip w/ exe and use NSIS

Problemratgeber

Mehrfache Excel-Prozesse
Falls mehrere voneinander unabhängige Excel-Prozesse parallel laufen (und nicht nur mehrere Hauptfenster), sind Zugriffe auf »Excel.Cells« eventuell nicht möglich (Fehler-Code -2146827284)

Seiteninformationen und Impressum   |   Mitteilungsformular  |   "ram@zedat.fu-berlin.de" (ohne die Anführungszeichen) ist die Netzpostadresse von Stefan Ram.   |   Eine Verbindung zur Stefan-Ram-Startseite befindet sich oben auf dieser Seite hinter dem Text "Stefan Ram".)  |   Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram. Schlüsselwörter zu dieser Seite/relevant keywords describing this page: Stefan Ram Berlin slrprd slrprd stefanramberlin spellched stefanram724097 stefan_ram:724097 Zu Python unter Windows Stefan Ram, Berlin, and, or, near, uni, online, slrprd, slrprdqxx, slrprddoc, slrprd724097, slrprddef724097, PbclevtugFgrsnaEnz Erklärung, Beschreibung, Info, Information, Hinweis,

Der Urheber dieses Textes ist Stefan Ram. Alle Rechte sind vorbehalten. Diese Seite ist eine Veröffentlichung von Stefan Ram.
https://www.purl.org/stefan_ram/pub/windows_python