X-Received: by 2002:ae9:f205:: with SMTP id m5mr1616881qkg.152.1576663649043; Wed, 18 Dec 2019 02:07:29 -0800 (PST) X-Received: by 2002:aed:2906:: with SMTP id s6mr1380130qtd.12.1576663648811; Wed, 18 Dec 2019 02:07:28 -0800 (PST) Path: csiph.com!xmission!news.alt.net!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g89no2981174qtd.0!news-out.google.com!w29ni1897qtc.0!nntp.google.com!g89no2981168qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.python Date: Wed, 18 Dec 2019 02:07:28 -0800 (PST) In-Reply-To: <5df7b2b9$0$503$65785112@news.neostrada.pl> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=185.80.118.59; posting-account=Fo7zdgoAAABGKssuFnERA3oNSS91bR7E NNTP-Posting-Host: 185.80.118.59 References: <5df7b2b9$0$503$65785112@news.neostrada.pl> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Unicode From: damian@swistowski.org Injection-Date: Wed, 18 Dec 2019 10:07:29 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lines: 45 Xref: csiph.com pl.comp.lang.python:152 W dniu poniedzia=C5=82ek, 16 grudnia 2019 16:37:14 UTC u=C5=BCytkownik Ceza= ry Gr=C4=85dys napisa=C5=82: > Witam. > Sorry za lamerstwo, ale mam w pliku (json) linie typu: >=20 > "sender_name": "Cezary Gr\u00c4\u0085dys", >=20 > Chc=C4=99 z tego zrobi=C4=87 >=20 > "sender_name": "Cezary Gr=C4=85dys", >=20 >=20 > Szkielet skryptu taki: >=20 >=20 > #!/usr/bin/python3 >=20 > import sys > import re >=20 > try: > f =3D open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin > except FileNotFoundError: > print("Brak pliku") > exit(1) > except PermissionError: > print("Brak dost=C4=99pu do pliku") > exit(1) >=20 >=20 >=20 > for line in f: > line =3D line.strip() >=20 > # co tu wstawi=C4=87 ???? >=20 > print(line) >=20 >=20 >=20 - print(p['content']) # w tej linii b=C5=82=C4=85d, chocia=C5=BC kilka wyp= isuje. + print(p.get('content', '')) # w tej linii b=C5=82=C4=85d, chocia=C5=BC ki= lka wypisuje.