31 lines
811 B
Python
31 lines
811 B
Python
#import locale
|
|
# System-Standardkodierung anzeigen
|
|
#print(locale.getpreferredencoding(False))
|
|
|
|
# Beispiel: Datei in einem bestimmten Ordner speichern
|
|
# Pfad zur Datei (z. B. auf Windows)
|
|
|
|
from pathlib import Path
|
|
|
|
msg = "Save as ..."
|
|
path = get_string(msg, default = "/home/gac-x11ma/pshell/home/script/beamline_alignment/0012.txt", alternatives = None, password = False)
|
|
index = 0
|
|
status = 0
|
|
|
|
try:
|
|
zeilen = ['Das ist die erste Zeile.', 'Hier kommt die zweite Zeile.', 'Und das ist die dritte Zeile.']
|
|
|
|
with open(path, "w") as file1:
|
|
for zeile in zeilen:
|
|
file1.write(zeile + "\n")
|
|
print ("Datei wurde erfolgreich in " + path + " geschrieben.")
|
|
|
|
except:
|
|
index = 1
|
|
status = "Exception:" #, sys.exc_info()[2]
|
|
print ("Aborted by user.")
|
|
|
|
# return index, status
|
|
|
|
|