Die Suche ergab 11 Treffer

von nvidia11
Donnerstag 5. Februar 2015, 01:01
Forum: Allgemeine Fragen
Thema: JSON Umlaute
Antworten: 11
Zugriffe: 13933

Re: JSON Umlaute

ok das hat geklappt.
von nvidia11
Dienstag 3. Februar 2015, 23:14
Forum: Allgemeine Fragen
Thema: GZip Encoding
Antworten: 7
Zugriffe: 1141

Re: GZip Encoding

Ja ich hab es nun:

writer = codecs.getwriter("utf-8")
with gzip.open("/Users/user/Desktop/Try/trains.json.gz", mode="w") as outfile:
json.dump(fdata, writer(outfile), indent=2, ensure_ascii=False)

Aber es ist viel langsamer als

with gzip.open("/Users/user/Desktop/Try/trains.json.gz", mode="w ...
von nvidia11
Montag 2. Februar 2015, 01:09
Forum: Allgemeine Fragen
Thema: GZip Encoding
Antworten: 7
Zugriffe: 1141

Re: GZip Encoding

with gzip.open("/Users/user/Desktop/Try/trains.json", "w") as outfile:
t = codecs.StreamWriter(outfile)
# t = codecs.s(d, encoding="utf-8")
d = json.dump(fdata, t, indent=2, ensure_ascii=False)

Das hier wirft einen NotImplemented Error und bei codecs.StreamWriter kann ich auch kein Encoding mit ...
von nvidia11
Montag 2. Februar 2015, 00:16
Forum: Allgemeine Fragen
Thema: GZip Encoding
Antworten: 7
Zugriffe: 1141

Re: GZip Encoding

Hast du da mal ein Beispiel, mit der Doku komm ich nicht ganz klar:

# -*- coding: utf-8 -*-
import json
from collections import OrderedDict
import codecs
import gzip

fdata = OrderedDict()
#fdata = {}
fdata[u"Züge"] = 0#data
fdata[u"Bahnhöfe"] = 0#train_stations

with codecs.open("/Users/user ...
von nvidia11
Sonntag 1. Februar 2015, 23:43
Forum: Allgemeine Fragen
Thema: GZip Encoding
Antworten: 7
Zugriffe: 1141

GZip Encoding

with codecs.open(sys.argv[5] + ".json", "w", encoding="utf-8") as outfile:
json.dump(fdata, outfile, indent=2, ensure_ascii=False)

Das ist bis jetzt mein Code. Ich möchte die Daten nun beim schreiben komprimieren.
Leider wenn ich gzip.open() benutze kennt er in Python 2.7 noch nicht encoding.

Wie ...
von nvidia11
Freitag 30. Januar 2015, 23:59
Forum: Allgemeine Fragen
Thema: JSON Umlaute
Antworten: 11
Zugriffe: 13933

Re: JSON Umlaute

Ja srry :D
# -*- coding: utf-8 -*-
import json
from collections import OrderedDict

fdata = OrderedDict()
fdata[u"Züge"] = 0#data
fdata[u"Bahnhöfe"] = 0#train_stations

with open("/Users/user/Desktop/Try/trains.json", "w") as outfile:
json.dump(fdata, outfile, indent=2, ensure_ascii=False)
Es ...
von nvidia11
Freitag 30. Januar 2015, 23:26
Forum: Allgemeine Fragen
Thema: JSON Umlaute
Antworten: 11
Zugriffe: 13933

JSON Umlaute

dict = {}
dict[u'Züge'] = 0

json.dumps(dict, file, ensure_ascii=false)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 2: ordinal not in range(128)

wie kann man das beheben?

ich möchte, dass man später im File das ü sieht!
von nvidia11
Mittwoch 28. Januar 2015, 16:08
Forum: Allgemeine Fragen
Thema: Syntax Error Format String Python 2.7
Antworten: 1
Zugriffe: 610

Syntax Error Format String Python 2.7

W = "\033[0m" # white (normal)
R = "\033[31m" # red

ascii_art = "" \
"{0} .-----. {1} .-----. \n".format(W,W) \
"{0} \ / {1} \X/ \n".format(W,W)
print ascii_art
Python 2.7 Syntax Error.

Ich verstehe nicht warum?
von nvidia11
Montag 8. Dezember 2014, 19:40
Forum: Allgemeine Fragen
Thema: Professionelle Python Entwicklung
Antworten: 10
Zugriffe: 1871

Re: Professionelle Python Entwicklung

@1 ok also keine globalen Variablen :D
Wann sind denn globale Variablen sinnvoll?

@2 ich war zu faul immer das ab zu tippen, die _ Striche damit ich das Objekt von der Klasse nochmal ohne den _ erzeugen kann mit dem gleichen Namen
Ja xml dachte ich mir, weil man es dann auch mal anschauen kann und ...
von nvidia11
Montag 8. Dezember 2014, 18:05
Forum: Allgemeine Fragen
Thema: Professionelle Python Entwicklung
Antworten: 10
Zugriffe: 1871

Re: Professionelle Python Entwicklung

Vielen Dank für die Antworten!

Also ja bis jetzt ist es ein Skript ohne irgendeine Funktion.

Mein Vorgehen:

Ich führe eine main-methode ein und dann für jedes beschriebene Teilgebiet eine eigene Funktion.

1) click sieht sehr gut aus! Ich hätte vorgeschlagen, da es sehr viele Parameter sind und ...
von nvidia11
Montag 8. Dezember 2014, 00:39
Forum: Allgemeine Fragen
Thema: Professionelle Python Entwicklung
Antworten: 10
Zugriffe: 1871

Professionelle Python Entwicklung

Wie sieht kommerzielle Pythonentwicklung aus?
Ich hab eine Konsoleanwendung geschrieben, die zusammgehackt ist.
Sie parst Argumente, ließt Dateien ein, baut ein Model, ruft externe Optimierungsoftware auf, und schreibt das Ergebnis in eine Datei und kann Plots erstellen.
Im moment hab ich Pycharm ...