FreeKB - Python (Scripting) articles
Python (Scripting) articles

ArraysGetting Started with ArraysAppend values to the end of an arrayBlank out an arrayCount the elements in an arrayRemove duplicate values from an arrayClassesCalling classes from another Python scriptGetting Starting with ClassesCommand line optionsCommand line options flags argumentsCommandsConfigure the "python" command to invoke the "python3" commandpython --version commandDate and Timedate and timedef (function)Getting Started with functionsCalling functions from another Python scriptPass values into a functionReturn value in a functionemailSend an emailexitStop Halt or ExitFileRead a file (open)Write or Append to a file (open)FTPConnect to an FTP ServerHashesGetting Started with Hasheshash has_keyhostnamehostname (socket)if elif else statementif elif else statementsImportimport moduleInstallInstall pycharm on LinuxInstall Python on Linux CentOSJSONDetermine if JSON key contains a valueDetermine if JSON key contains an empty arrayDetermine if JSON key existsLoop through JSON arrayParse JSON file using json.loadParse JSON string using json.loadsLoopsBreak out of a loopLooping over a variable using split or splitlinesLooping over an arraymatchFind matching expression using findFind matching expression using re.matchMathAddition and Increment (+)Division (/)Subtraction and DecrementModulessys.pathNative operating system commandsNative operating system commandsos.accessDetermine if an file or directory is readable writable (os.access)os.pathDetermine if a file or directory exists (os.path.exists)Determine if an object is a file or directory (os.path.isfile isdir)directory name (os.path.dirname)file basenameReturn scriptname using os.path.basenamePrinting outputPrinting text to the console (print)ReplaceReplace and re.subREST API (curl)Getting Started with requests REST API (curl)Spliting stringSplit or cut apart a stringTroubleshootingResolve "TypeError: cannot concatenate 'str' and 'bool' objects"Resolve "TypeError: cannot concatenate 'str' and 'list' objects"try except elsetry except else finallyUpper Lower CaseUpper Lower Case using upper lowerVariablesAppend to a variableDefining variablesVersionpython --version commandVirtual EnvironmentActivate a virtual environmentCreate a virtual environment (venv virtualenv)Installing packages in a virtual environment

Web design by yours truely - me, myself, and I   |   |