Python Text Processing---Calculate the number of different amino acids in the Fasta file

#::!/usr/bin/python3#-*-coding:utf-8-*- # calculate the content of each amino acid in the Fasta file ImportSysargs=SYS.ARGVF=open (Args[1],'R') FW=open ('OUT.txt','W') Line=f.read () txt="'. Join (Line.split ('\ n') [1:])#can get the amino acid

A. Python multithreaded instance multi-threaded lock

1. MultithreadingMulti-threaded and multi-process representation is almostMulti-Threading for IO-intensiveThe thread is the smallest unit in the applicationThere are two ways to implement multithreading:Method One:The method to be executed is passed

Python multi-Threading with Gil

the GIL and Python threads are entangledWhat is GIL? What effect does it have on Python programs? Let's look at a question first. What is the CPU usage of this Python code?# do not imitate at work, Danger:) def Dead_loop (): while True:

Python error runtimeerror:dictionary changed size during iteration

Pythonn error message:C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe c:/users/administrator/ pycharmprojects/pythondemo/maptest.pyTraceback (most recent): File

Python note nine (iteration)

First, iterationThrough a for loop to iterate through a list, we call this traversal the same way as iteration . An iterative operation can be performed as long as an iterative object is available.The following code can be used to determine whether

Python compresses files/folders with Python

"Python compressed folder" Import "ZipFile" module1 defZip_ya (startdir,file_news):2Startdir =". \\123" #the folder path to compress3File_news = Startdir +'. zip' #the name of the folder after compression4z = zipfile. ZipFile (File_news,'W',

Python Learning 2

First, Sort:1. Using the method sort () to sort the list permanently2. Use function sorted () to sort the list temporarilyNote: reverse () does not refer to arranging list elements in the opposite order of alphabetical order, but simply reversing

Python Regular Expressions

1. If the special characters are literal in use, they need to precede them with a backslash (\) and special characters include \. ^ $ ? + * { } ( ) [ ] |2. If you want to match any one of the character sets, you can use the character class to

Python Basics-File manipulation

‘‘‘Unicodedecodeerror: ' GBK ' codec can ' t decode byte 0x80 in position 106:illegal multibyte sequenceEncoding= "Utf-8"Windows defaults to using the GBK‘‘‘#data =open ("Chaochao", encoding= "Utf-8"). Read ()‘‘‘F=open ("Chaochao", ' R ', encoding= "

Resolving garbled problems encountered in Python

1. A feasible way to solve Chinese garbled characters1 #-*-coding:utf-8-*-2 from __future__ Importunicode_literals3 4 ImportChardet5 6 7 defSmart_decoder (Raw_content, default_encoding_list= ("Utf-8","GB18030")):8 """9 decodes a string into

Python:os module and SYS module common functions

Print (Sys.path) #打印环境变量name.py:Print (SYS.ARGV)Enter Python name.py 123 at the command line, output name.py 123 in turnOs.system ("dir") #打印当前目录下的文件, if the value returned successfully is 0, the value returned by the failure is not 0 (that is, it

python--palindrome function (reversed)

Palindrome number: The positive and reverse permutations result in equal (i.e., left-to-right and right-to-left results are equal), for example: "123321", "0000" and so on.Reversed function: Reverses a Sequence object and constructs its elements

Requests crawl Baidu paste: Python beauty 3

Import Requestsimport Sysclass Tieba (object): Def __init__ (self, tieba_name, pn): Self.tieba_name = Tieba_name Self.base_url = ' https://tieba.baidu.com/f?kw=%spn= '% (tieba_name) # print (Self.base_url) self.url_li st = [] for i in range

Python Builder (Generator)

First, why use the generator:With list generation, we can create a list directly. However, with memory limitations, the list capacity is certainly limited. Also, creating a list of 1 million elements takes up a lot of storage space, and if we just

Python Strip () method

DescriptionThe Python Strip () method removes the character specified by the string's Kinsoku (the default is a space).GrammarStrip () method syntax:Str.strip ([chars]);ParametersChars--Removes the character specified by the tail of the

Python programming Exercise: The arithmetic of a leaky device

When I read the last "what to learn" in the concise Python tutorial, I discovered that it was a graphical tool, and that if you mastered the previous chapters, you could write most programs = =! Well, I've been reading books and haven't written any

Python configuration file read/write

Configparser module One, create a configuration file in the D disk to establish a configuration file, the name is: Test.ini content as follows: [Baseconf]host=127.0.0.1port=3306user=rootpassword=rootdb_

Use Python to make the simplest crawler

Use Python to make the simplest crawler--The Heart#第一种方法Import urllib2 #将urllib2库引用进来Response=urllib2.urlopen ("http://www.baidu.com") #调用库中的方法 to encapsulate the request response into the response objectHtml=response.read () #调用response对象的read ()

Python Crawler requests Judge request timeout and resend request

In the execution of the crawler, there will always be a request connection timeout situation, the following code block in the case of a request time-out, catch a time-out error and continuously send multiple requests, only to the request to connect

Apriori algorithm Python implementation

1. Introduction to the Apriori algorithmThe Apriori algorithm is an algorithm for mining the frequent itemsets of Boolean association rules. The Apriori algorithm uses a priori knowledge of the nature of frequent itemsets, and through the iterative

Total Pages: 4013 1 .... 2193 2194 2195 2196 2197 .... 4013 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.