When you write Python scripts, you may want to perform certain actions, such as reading or writing to a file, only if the file exists.
Continue readingSave a NumPy Array to a Text File in Python
You can save the NumPy array to a text file using the savetxt() function.
Continue readingAdd to a Dictionary in Python
If you work with data structures, such as dictionaries, you may wonder whether you can add or append an item the same way as you can do it with a list? Read the rest of the article to find out.
Continue readingRemove Character from String in Python
The replace() function searches for a specified pattern in a string and replaces it with another specified string.
Continue readingConvert String to Hex in Python
The hex() function can be used to convert a string to a hexadecimal value. Before using the function the value has to be converted to bytes.
Continue readingConvert Hex to String in Python
This is a tutorial on how to convert hexadecimal numbers to strings in Python. When working with hex numbers, it can be difficult to read or compare them, so converting them to strings will make the process easier.
Continue readingAppend Text to a File in Python
Python offers several file access modes. One of them is “append”. This mode allows you to place the cursor at the end of the text file to insert the new lines there.
Continue readingRemove a String From a List in Python
Elements from the list (including strings) can be deleted using the remove() function.
Continue readingConvert String to JSON in Python
Function json.loads() accepts JSON string and converts it to Python dictionary (deserialization). The last letter in load(s) stands for “string”.
Continue readingHow to Write to Text File in Python
To write to a text file in Python, you have to use the open() and write() functions. The open() function takes two parameters: file name and file access mode. The returned value of open() is the file object.
Continue reading