.split() - separates a string into multiple strings, arranges them in a list, and returns the list according a defined separator
note! default separator is any whitespace
Example
string = 'Gm01:1234..5678:Gm01g12345'
string.split(':')[1].split('..')[0] = '1234'
.strip() - removes all the leading and trailing spaces from a string
.replace('a' , 'b') - replaces all the 'a' into 'b' in a string
.append(element) - adds a single element to the end of the existing list
.insert(idx,element) - adds a single element to the defined index of the exisintg list
.remove(element) - removes the first defined element from a list
.pop(idx) - removes and returns the last element from the list or the defined index element
'str'.join(list) - takes all the elements from the list and joins them into a single string using 'str'
list() - a constructor returns a list
.keys() - takes all keys from the dictionary and returns elements as a list
.values() - takes all values from the dictionary and returns elements as a list
open() - is used to open a file in specified mode and returns the file object
Usage
→open('file_name', 'r')._____
→open('file_name', 'w')._____
._____
.read() - takes a text file as input and returns the whole file object into a string
.readlines() - takes a text file as input and stores each line in the file as a separate element in a list
note! lines = line + 1
lines + = 1
→do the same thing
'Bioinformatics' 카테고리의 다른 글
Phylogenomics (0) | 2023.04.13 |
---|---|
Python4 (0) | 2023.02.09 |
Python2 (0) | 2023.01.02 |
Python1 (0) | 2022.12.31 |
Linux - Ubuntu (0) | 2022.12.27 |