Manage PlItems

You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.

Advanced Search
Displaying 91-100 of 300 results.
IDPlCodelangPlGroupPlItemTitleCode 
 
70PythonFilehandlingVerzeichnis rekursiv durchsuchenimport os searchPath = '/home/patrick/Desktop/' # os.walk will go through all subdirectories for pathentry in os.walk(searchPath, False): for dir in pathentry[1]: path = os.path.join(pathentry[0], dir) if os.path.islink(path): print path + "... is a link" # os.unlink(path) else: print path + "... is a dir" # os.rmdir(path) for file in pathentry[2]: path = os.path.join(pathentry[0], file) # os.unlink(path) print path + "... is a file" # os.listdir only the given path for file in os.listdir(searchPath): fullfilename = os.path.join(searchPath, file) if os.path.isfile(fullfilename): print fullfilename + "... is a file"View Update Delete
76PythonNetzwerk, EmailEmail versenden# Found at (and little modified): http://www.semi-legitimate.com/sls/blog/37-quick-notes/62-command-line-smtp-from-python #!/usr/bin/python import smtplib, sys if len(sys.argv) != 5: print "You must call me like:" print " mailme from to subject msgfile" sys.exit() fromadr = sys.argv[1] toadr = sys.argv[2] subject = sys.argv[3] msgfile = sys.argv[4] try: f = open(msgfile) msg = f.read() except: print "Invalid Message File: " + msgfile sys.exit() m = "From: %s To: %s Subject: %s X-Mailer: My-Mail " \ % (fromadr, toadr, subject) smtpserver="mysmtp.lan" loginuser="Marty_McFly" loginpwd="DeLorean" smtp = smtplib.SMTP() smtp.connect(smtpserver) smtp.login(loginuser, loginpwd) smtp.ehlo() smtp.sendmail(fromadr, toadr, m+msg) smtp.close() View Update Delete
125PythonEncoding / DecodingDatei nach Base64 encodierenmyfile = 'myDoc.pdf' ReturnValue = open(myfile).read().encode("base64") # in ReturnValue ist nun der Base64-StringView Update Delete
128PythonKonsolenverwaltungEinlesen Konsoleneingabeyourname = raw_input('What\'s your name? ')View Update Delete
155PythonDatum, ZeitAktuelles Datum/Uhrzeitfrom datetime import date iso_datum = date.today().isoformat() output = iso_datum print output # 2013-12-05 # or import datetime datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") # 2013-12-05_18-09-10View Update Delete
159PythonTextdateienTextDatei auslesenmyFilename = "file.txt" fileObj = open(myFilename , "r" ) array = [] for line in fileObj: array.append( line ) fileObj.close()View Update Delete
160PythonExceptionsTry Catch Excepttry: print 1/0 except Exception as e: print traceback.extract_stack() else: print "this is the else block" finally: print "finally clean up or something"View Update Delete
161PythonStringsString nach einem Teilstring durchsuchen# http://www.tutorialspoint.com/python/string_find.htm # this function is case sensitive fullstring = "This is my string" searchFor = "my" startPosition = fullstring.find(searchFor, 0, len(fullstring)) # startPosition will have 8 if startPosition>=0: print "I found it!" startPosition = fullstring.upper().find(searchFor.upper()) # case insensitiveView Update Delete
162PythonStringsString auf Wunschlänge zuschneidenmyString = "Benzinverbrauch" print myString[2:10] # Ausgabe: "nzinverb"View Update Delete
164PythonVariablenAuflistung aller Variablenimport pprint a="This is a test" b=1 c=True pprint.pprint(locals()) #{'__builtins__': <module '__builtin__' (built-in)>, # '__doc__': None, # '__name__': '__main__', # '__package__': None, # 'a': 'This is a test', # 'b': 1, # 'c': True, # 'pprint': <module 'pprint' from '/usr/lib/python2.7/pprint.pyc'>} pprint.pprint(globals())View Update Delete