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 181-190 of 300 results.
IDPlCodelangPlGroupPlItemTitleCode 
 
178C#FilehandlingPrüfen ob Datei existiertString filePath = "C:\\User\\myUser\\text.txt"; if (System.IO.File.Exists(filePath)) { MessageBox.Show("There it is! ;-)"); } else { MessageBox.Show("Whow, file is missing at this place :-("); }View Update Delete
274PythonStringsLeerzeichen vor/hinter String entfernenmyText = " x text x \r\n" print myText.strip()View Update Delete
280PythonFilehandlingPrüfen ob Verzeichnis existiertimport os.path from os import path myFolder = "/tmp/test" if path.exists(myFolder) & path.isdir(myFolder): print "Folder exists!" else: print "Folder doesn't exist!"View Update Delete
281PythonFilehandlingVerzeichnis erstellenimport os myFolder = "/tmp/test" try: os.mkdir(myFolder) except OSError: print ("Error creating directory: %s" % myFolder) else: print ("Directory created: %s " % myFolder)View Update Delete
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