The fastest way to convert a list (array) to a string is to use the join function.
Continue readingAuthor Archives: Tomasz Decker
How to Argparse File in Python
In this tutorial, I’ll show you how you can open and read a text file using command line arguments.
Continue readingAppend String to a List in Python
If you want to append a string to a list, you can do it using the append function.
Continue readingAppend String in a Loop in Python
If you have a list of strings and you want to concatenate them to create a single string made of these elements, you can use the For loop.
Continue readingAppend One String to Another in Python
The simplest way to append one string to another is by using the addition operator. The same as you use to add two numbers.
Continue readingHow to Convert Unicode to String in Python
You can convert Unicode characters to an ASCII string using the encode function.
Continue readingSort List by Key in Python
When we sort a list it’s sorted by values. If we have a list of tuples, it’s sorted by the first element by default.
Continue readingInstall BeautifulSoup Using PIP
To install BeautifulSoup, follow these steps:
Continue readingClear File in Python
The quickest way to clear file contents in Python is by using the following code:
1 2 |
file = open("D:/my_file.txt","w") file.close() |
Append a File to a List in Python
Last time I wrote an article on how to write a list to a file. This time we are going the other way around: How to read data from a file and write it to a list.
Continue reading