-- Leo's gemini proxy

-- Connecting to gemini.tuxmachines.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-GB

Tux Machines


Python Leftovers


Posted by Roy Schestowitz on May 25, 2023


today's howtos

Android Leftovers



Remove Special Characters From String Python


↺ Remove Special Characters From String Python


> To remove special characters from a string the “regular expressions”, “looping”, “join(), and filter()” methods, and the “replace()” method are used in Python.



Python Compile() Function


↺ Python Compile() Function


> The “compile()” function in Python is a built-in function that is utilized to compile Python code into “bytecode” by accepting several parameters.



Matplotlib Pie Chart


↺ Matplotlib Pie Chart


> To create a pie chart in Python, the “matplotlib” library’s “pie()” function can be used along with the multiple required parameters.



How to Copy a File in Python


↺ How to Copy a File in Python


> To copy a file various methods are used in Python such as “shutil.copyfile”, “shutil.copy()”, “read()” with “write()” and “shutil.copyfileobj()”.



NumPy Inverse


↺ NumPy Inverse


> The “numpy.linalg.inv()” function of the “numpy.linalg” module is utilized to compute the inverse of the given nonsingular matrix.



Python Next() Function


↺ Python Next() Function


> The Python “next()” function iterates over an iterable object and returns the next item from the iterable and stops with the exception when no items are left.



Python Sorted Reverse


↺ Python Sorted Reverse


> The “sorted()” function is used to sort the strings, lists, tuples, etc. in ascending or descending order or based on single or multiple “key” parameter values.



Python Remove all Instances From List


↺ Python Remove all Instances From List


> To remove all instances from the input string in Python, the “remove()”,  “filter()”, and “list comprehension” methods are used.



Python Finds the String in the File and Print


↺ Python Finds the String in the File and Print


> The “built-in file” operations, “regular expressions'', “read()” and “readlines()” methods are used to find a string in a file and print it in Python.



Overwrite a file in Python


↺ Overwrite a file in Python


> Python has several methods for overwriting files such as the “write()” method, the “truncate()” method, the mode “w”, “shutil” module, or the “os” module, etc.



Python string comparison


↺ Python string comparison


> To compare strings in Python, various methods such as the “Comparison Operators” or the “is” and “is not” operators are used.



Matplotlib Vertical Line


↺ Matplotlib Vertical Line


> To create single or multiple vertical lines and spans on your plots various methods such as “axvline()”, “vlines()”, and “ax.axvspan()” are used in Python.



Pandas to records


↺ Pandas to records


> The Pandas “to_records()” method converts a DataFrame to a NumPy record array, which can be exported to other applications.



List Files in a Directory Python


↺ List Files in a Directory Python


> To list files in a directory in Python, apply the “os.listdir()”, “glob.glob()”, “os.walk()”, “scandir()” functions or the “pathlib.Path.glob()” method.



Python Dictionaries


↺ Python Dictionaries


> Python “dictionaries” are a flexible data structure used in a broad range of applications and can be created via “curly braces {}” or “dict()” function.




gemini.tuxmachines.org

-- Response ended

-- Page fetched on Thu Jun 13 07:10:25 2024