Forum » Programiranje » Python | prekodiranje šumnikov
Python | prekodiranje šumnikov
HotBurek ::
Dobro jutro.
Iščem simple fix, ki sicer obstaja, a ga trenutno že predolgo iščem.
Kako string %C4%8Doko prekodirat v čoko z ta pravo built in funkcijo?
Iščem simple fix, ki sicer obstaja, a ga trenutno že predolgo iščem.
Kako string %C4%8Doko prekodirat v čoko z ta pravo built in funkcijo?
input = "%C4%8Doko"; out = input.encode("w00t").decode("utf-8"); print(out);
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
HotBurek ::
To je to! Hvala.
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
HotBurek ::
Dobro jutro.
Spet imam podobno zadevo, a ne isto. Kako string konvertat v "normalen" string.
Primer:
---------------------------
UPDATE
Našel rešitev.
Primer:
Spet imam podobno zadevo, a ne isto. Kako string konvertat v "normalen" string.
Primer:
input = "Snickers “čeznočna” kaša";
---------------------------
UPDATE
Našel rešitev.
Primer:
import html; input = "Snickers “čeznočna” kaša"; output = html.unescape(input); print(output);
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Zgodovina sprememb…
- spremenilo: HotBurek ()
HotBurek ::
Še en svež primer:
Output:
Je treba dvakrat naredit.
Sem pa videl, če se to (html.unescape) naredi 5x, da potem nič ne spremeni na output-u.
Bi bilo zanimivo imeti v loop-u, dokler ne pride do "konca". Samo kako definirat "konec"?
Hm, mogoče v loop-u, in dokler sta output in input različna, se loopa, potem pa stop.
We will see.
import html; input = "CIMET & POMARAN\u010cA"; print(input); output = html.unescape(input); print(output); output = html.unescape(output); print(output);
Output:
CIMET & POMARANČA CIMET & POMARANČA CIMET & POMARANČA
Je treba dvakrat naredit.
Sem pa videl, če se to (html.unescape) naredi 5x, da potem nič ne spremeni na output-u.
Bi bilo zanimivo imeti v loop-u, dokler ne pride do "konca". Samo kako definirat "konec"?
Hm, mogoče v loop-u, in dokler sta output in input različna, se loopa, potem pa stop.
We will see.
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
HotBurek ::
Je šlo z uporabo loop-a.
Primer:
Output:
Primer:
import html; input = "CIMET & POMARAN\u010cA"; print("Input: " + input); maxdepth = 5; output = ""; for i in range(0, 5): output = html.unescape(input); print("[" + str(i) + str("] ") + input); print("[" + str(i) + str("] ") + output); if output != input: input = output; else: break; print("Output: " + output);
Output:
Input: CIMET & POMARANČA [0] CIMET & POMARANČA [0] CIMET & POMARANČA [1] CIMET & POMARANČA [1] CIMET & POMARANČA [2] CIMET & POMARANČA [2] CIMET & POMARANČA Output: CIMET & POMARANČA
root@debian:/# iptraf-ng
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
fatal: This program requires a screen size of at least 80 columns by 24 lines
Please resize your window
Zgodovina sprememb…
- spremenilo: HotBurek ()
MrStein ::
Ali pa rečeš izvoru input-a, naj neha bedarije pošiljati. (sicer to ni vedno možno)
Motiti se je človeško.
Motiti se pogosto je neumno.
Vztrajati pri zmoti je... oh, pozdravljen!
Motiti se pogosto je neumno.
Vztrajati pri zmoti je... oh, pozdravljen!
gwtlwesncw ::
To je bolj akademska (teoretična) zadeva, rešiš poceni iterativno (ne drago rekurzivno), dokler je string možno de-entitizirat, že moraš vedeti, zakaj :-)
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | CSV fileOddelek: Programiranje | 1790 (994) | kunigunda |
» | python regex splitOddelek: Programiranje | 552 (457) | HotBurek |
» | Python permutacije slo. besedOddelek: Programiranje | 2308 (1754) | epsilon |
» | [MariaDB] Kolikokrat se pojavi tekst v tekstu?Oddelek: Programiranje | 816 (509) | BigWhale |
» | [JAVA] zaustavitev niti (threadov)Oddelek: Programiranje | 3174 (3174) | morbo |