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 201-210 of 300 results.
IDPlCodelangPlGroupPlItemTitleCode 
 
191PythonEncoding / Decodingmd5-Hash erzeugen# https://docs.python.org/2/library/hashlib.html import hashlib a = "hello world" b = 0.1 md5str = hashlib.md5(str(b) + a).hexdigest() View Update Delete
192PythonFilehandlingPrüfen ob Datei existiertimport os filePath="/home/myUser/test.txt" if (os.path.isfile(filePath)): print "There it is! ;-)" else: print "Whow, file is missing at this place :-(" View Update Delete
193PythonArrayDictionary Basics# empty dict myDict = {} # some static values myDict ={ "key1" : {"item1":"value1"}, "key2" : {"itemX":"valueY"}, "keyX" : {"item99":"value98"} } # update a key programmatically myDict.update({"key1" = {"item2":"new value"}}) # iterate for (key, subdict) in myDict.items(): current_key = key current_subdict = subdict # get an specific item subdict = myDict.get("key2") print subdict.get("itemX") # valueYView Update Delete
194PythonFilehandlingFilename-Manipultation Basicsimport os myFilename = "/tmp/Test/myFile.txt" # Get only the path path_only = os.path.dirname(myFilename) # /tmp/Test # Filename only filename_only = os.path.basename(myFilename) # myFile.txt # get only filename without extention filename_without_ext = os.path.basename(os.path.splitext(myFilename)[0]) # myFile # get only the extension filename_extention_only = os.path.splitext(myFilename)[1] # .txt # put them together again myFilename_together = os.path.join(path_only, filename_without_ext + filename_extention_only) # /tmp/Test/myFile.txt View Update Delete
195PythonExceptionsException auslösenif (a!=b): raise Exception("Not implemented, yet")View Update Delete
196PythonJSONJSON Daten ladenimport json myJSONFile = "/tmp/Test/myData.json" json_data = open(myJSONFile) # In Python werden JSON Daten nach dem Laden wie Dictionaries behandelt data_dict = json.load(json_data)View Update Delete
197PythonJSONJSON Daten speichernmyData_dict = {"key1":"value1"} fileObj = open('myData.json', 'w+') jsonDump = json.dumps(myData_dict) fileObj.write(jsonDump) fileObj.close()View Update Delete
204PythonFallunterscheidungTernary operatorthisVar = "OK" resultVar = False # [on_true] if [cond] else [on_false] resultVar = True if thisVar == "OK" else False // same as if-else construction if (thisVar == "OK"): resultVar = True else: resultVar = FalseView Update Delete
215PythonStringsReplace# http://www.tutorialspoint.com/python/string_replace.htm str1 = "abc#def" str1 = str1.replace("#",';") print str1 # Output: abc;defView Update Delete
240PythonStringsText in Großschrift oder KleinschriftmyString = "my lovely Mr Singing Club" print myString.upper() // MY LOVELY MR SINGING CLUB print myString.lower()View Update Delete