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 131-140 of 300 results.
IDPlCodelangPlGroupPlItemTitleCode 
 
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
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
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
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
249PythonSysteminfoBetriebssystem ermittelnimport os os.name # nt, posix import platform platform.system() # 'Windows', 'Linux', 'Darwin' platform.release() # Linux, Windows, Windows, Darwin '2.6.22-15-generic', 'Vista' ,'10', '8.11.1' # Example from https://stackoverflow.com/questions/1854/python-what-os-am-i-running-on from sys import platform as _platform if _platform == "linux" or _platform == "linux2": # linux elif _platform == "darwin": # MAC OS X elif _platform == "win32": # Windows elif _platform == "win64": # Windows 64-bitView 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
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
37JavaGUI, Komponenten allgemeinL&F setzen/ändernimport javax.swing.UIManager; // Set the L&F to the standard OS-Theme UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // there are other possibilites and L&F-Sets... Just google ;-) // For example look at L2FProd or Substance...View Update Delete
30JavaZahlen/RechnenNachkommastellenimport java.text.*; // mindestens 1 Vorkommastelle, genau 2 Nachkommastellen DecimalFormat f = new DecimalFormat("#0.00"); double d1 = 1234.4843; double d2 = 0.2; System.out.println(f.format(d1)); System.out.println(f.format(d2)); // Ausgabe d1=1234,4843 <--- man beachte das Komma! // Ausgabe d2=0,2View Update Delete
36JavaGUI, Komponenten allgemeinPanel Größe ändernimport java.awt.Dimension; import javax.swing.JPanel; Dimension dim = new Dimension(); dim.height=300; dim.width=500; JPanel pan = new JPanel(); pan.setPreferredSize(dim); View Update Delete