How to Use the swapCase () method to convert case sensitivity in Python
This article describes how to use the swapCase () method to convert the case sensitivity in Python. It is a basic knowledge in Python. For more information, see
The swapCase () method returns all upperca
Use Python to easily convert IP addresses between integers and strings.
Preface
Everyone should have some experience. It is really a waste of space and performance for storing string-type IP addresses in the database, so cute people want to convert IP addresses to integer storage. INET exists in MySQL_ ATON (),INET_N
Sequence is the most basic data structure in Python. Each element in the sequence is assigned a number-its location, or index. The first index is 0, the second index is 1, and so on. Sequence is the most basic data structure in Python. Each element in the sequence is assigned a number-its location, or index. The first index is 0, the second index is 1, and so on.
Pytho
Assigning values to variablesVariable assignments in Python do not require a type declaration.Each variable is created in memory and includes information about the identity, name, and data of the variable.Python allows assigning values to multiple variables at the same timeA = b = C =1'b', 1.1 # assigns a value of 1, ' B ' to a, b,1.1 assignment to CStandard data typesPython has five standard data types
the right of the string by default. The execution result is helloprint ('\ nmysql abcd '. strip () # by default, the spaces and line breaks on both sides are removed. The execution result is mysql abcd. print ('mysqlmy') cannot be removed for spaces in the middle '. strip ('M') # Remove the specified string, for example, remove the m elements on both sides. Execution result: ysqlm y
The
#-*-coding:utf-8-*-#1, DictionariesDict = {' name ': ' Zara ', ' age ': 7, ' class ': ' First '}#字典转为字符串, return: Print type (str (dict)), str (DICT)#字典可以转为元组, return: (' age ', ' name ', ' class ')Print tuple (dict)#字典可以转为元组, return: (7, ' Zara ', ' first ')Print tuple (dict.values ())#字典转为列表, return: [' age ', ' name ', ' class ']Print List (dict)#字典转为列表Print Dict.values#2, tuplestup= (1, 2, 3, 4, 5)#元组转为字符串, return: (1, 2, 3, 4, 5)Print tup.__str__
format them to the specified position (uppercase E)
F. Convert integers and floating-point numbers to floating-point numbers and format them to the specified position (the default value is 6 digits after the decimal point)
F, same as above
G. It is automatically adjusted to convert integers and floating-point numbers into floating-point or scientific notation (more than 6 digits are counted in scientifi
entry. This is a necessary condition for distinguishing a single tuple from a method call, which will be discussed in detail in future articles. List is unnecessary, although a single comma is allowed.
As usual, to get more information about the Python topic, you can use the built-in help interpreter, for example, listing 2 shows the help description of how to start the
Python self-study day-Two day (2)-python-list-tuples-dictionary, python-
ListFormat: name = []Name = [name1, name2, name3, name4, name5]
# List operations
Name. index ("name1") # query the name of the specified value. count ("name1") # query the name of the total number of s
". Strip ())#go to all the carriage returns/spacesP= Str.maketrans ("abcdef","123456")#one by one corresponding Replacement/translationPrint("Alex Li". Translate (p))Print("Alex a A". replace ("a","A", 2))#Replace replacement, control numberPrint("Aebcdef". RFind ("e"))#Find it from the right and find the one on the right.Print("Alex Li Aa". Split ())#To convert a string to a
, 2,-4, 2])# Minimum value
Sum ([2,-1, 9, 12])# Sum
Type conversion
INT ("5 ")# Convert to integer
Float (2)# Converting to float
Long ("23 ")# Convert to a long integer
STR (0, 2.3)# Convert to string
Complex (3, 9)# Return the plural 3 + 9i
Ord ("")# Value corresponding to the "A" Character
CHR (
This article describes how to convert python images to pdf files in detail, which has some reference value, interested friends can refer to this article for details about the python image-to-pdf method, which has some reference value. interested friends can refer
Import OS
Import sys
From reportlab. lib. pagesizes import A4, landscape
From reportlab.pdf gen impo
This article mainly introduces how to convert the ancestor of python into an array, and describes how to use the list method in Python, for more information, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
The element of the
DescribeThe list () method is used to convert tuples to lists.Note: tuples are very similar to lists, except that the tuple's element values cannot be modified, the tuple is enclosed in parentheses, and the list is placed in square brackets.GrammarList () method syntax:List (seq)Parameters
List-the tuple to
Python print encoding has many application scopes. Here we will first look at how to convert the default encoding into system encoding. I hope you will have some gains. When encode is used and decode is used, it is always confused at the beginning.
In fact, the English name of various local Character sets is Coded Character Set. to convert it to Coded, it must be
). This 51a0 and 7434 represent 16 binary 4 bytes, which is Unicode encoding, Python certainly has to provide numbers to character or byte array to string function, you have to process them into numbers, and then go.Javascript:
this is actually
This is actually
UnicodeCode. Unicode uses a 16-bit integer to represent any character that exists in the world, that is, any character that can be displayed
Sequence
Index: Index is the key value of the PHP array. Starting from 0.Fragmentation: PHP's slice, if number[3:9] Note that the intercepted value starts at the 4th index.Step size: The stepping length of each operation of the fragment. Can not be 0, to be a negative number, that is, from the back forward.
Sequence addition: Connecting operations using the + number for sequenceTwo sequences of the same type can be added.Multiplying a sequence with a number x will generate a new sequence, and
Introduction to the lower () method used to convert lowercase letters in Python
This article mainly introduces the lower () method used in Python to convert letters to lowercase letters. It is a basic knowledge in Python learning. For more information, see
The lower () metho
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.