Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

python

Empfohlene Antworten

Veröffentlicht

hi,

hat einer von euch ahnung mit python? besser wie php?vorteile und nachteile?

wo muss ich die python datei hinpacken und was für eine endung müssen die haben?

wie sieht ein simples beispiel aus?

hat/kennt jemand eine deutsch pyhthon einführung?

danke schonmal

Python würde ich nicht mit php vergleichen, eher mit perl.

Mit Python kannst du besser auf Systemressourcen zugreifen als bei PHP, ist allerdings je nach Verwendungszweck auch eher gefährlich. Auf welchem System willst du den arbeiten?

Unter Linux brauchst du keine Dateiendungen. Du musst nur als erste Zeile

#!/pfad/zu/python
eintragen und diese Datei dann ausführbar machen. Auf Windows Systemen haben sie üblicherweise .py als script oder .pyc als precompiled Dateien. Ich finde Python ist eine der angenehmsten scriptsprachen. Pythoncode ist sehr gut lesbar, die Syntax schnell verstanden. Du kannst in scripten Erweiterungen modulariesiert, das heisst man kann Sachen nachladen, verwenden.

#!/usr/bin/python


import os

import time

import stringold

import MySQLdb


def insert_line(oneline):

    lineaslist = stringold.split(oneline,maxsplit=20)

    unixtime = stringold.atof(lineaslist[0])

    datum = time.strftime('%d.%m.%Y', time.localtime(unixtime))

    zeit = time.strftime('%H:%M:%S', time.localtime(unixtime))

    client = lineaslist[2]

    size = lineaslist[4]

    url = lineaslist[6]

    user = lineaslist[7]

    rest = str(lineaslist[8:])

    c.execute("""INSERT INTO logs (zeile, datum, zeit, client, size, target_url, user, rest) VALUES \

(%s, %s, %s, %s, %s, %s, %s, %s)""", (i, datum, zeit, client, size, url, user, rest))


db=MySQLdb.connect(user='xyz',passwd='geheim',db='squid')

c=db.cursor()

c.execute("""DELETE FROM logs""")

logfile = open('/var/log/squid/access.log','r')

i = 0

lines = logfile.readlines()

print "Starte..."

for x in lines:

    i = i+1

    insert_line(x)

print "fertig, aputzen!"

Dieses kleine Script liest z.B. die logdatei von Squid ein und schreibt sie in eine MySQL Tabelle. Vorher formatiert es noch Datum und Uhrzeit.

Blöcke werden anhand ihrer Einrückung erkannt (wie z.B. in der for schleife, if ist syntaktisch fast gleich).

http://www.thomas-guettler.de/vortraege/python/einfuehrung.html

http://www.lernnetz-sh.de/kmLinux/doc/Python-Einfuehrung/

http://wspiegel.bei.t-online.de/pykurs/

fallen mir so als spontane links ein, die alle auf deutsch sein müssten.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.