python learning (day1)

First, before the training, I had heard many times python language, but never really had to learn, just know that it is a currently very popular and very powerful language, can easily and quickly achieve a lot Features. I understand today's lesson with a python, and is regarded as a little get started, mainly to learn some basic syntax and data types in python string type (str) study is to understand the focus of the library, understand the use of function in python there are many applications, the learning function for learning and understanding of the string is the string associated built-in functions that are implemented through.

Today some of the basic data type contact and I was impressed by some of the operations

1. Digital Type: Integer: int float: float

2. String Type: Role: name, sex, nationality, address and other descriptive information

Definition: single quotation marks \ double quotes \ three marks, a string of characters

The priority control operations:
1, according to the index value (Forward + Reverse take take): can only take
2, sections (care regardless of the end, step)
3, the length len
. 4, the members in operation in and Not
. 5, shift In addition to the blank Strip
. 6, segmentation Split
. 7, loop

Need to know:
. 1, Strip, the lstrip, The rstrip
2, Lower, Upper
. 3, startsWith, endsWith
. 4, the format of the three kinds of games are played
. 5, Split, rsplit
. 6, the Join
. 7, Replace
. 8, isdigit

Second, in general today still have no small gain, tank teacher's lecture me on the python had a very strong interest, I believe I will make some considerable follow the footsteps of classroom training at this time of the week progress, and lay a solid foundation for a few weeks of training, make some excellent results come out.

Third, work:

name =”a1eX"

1) corresponding to the variable name is removed on both sides of the space values, and outputs the processing result

2) determining whether the value corresponding to the variable name to "a1" at the beginning, and outputs the result

3) corresponding to the variable name is determined whether the value of an "X" at the end, and outputs the result

4) the value of the variable name corresponding to the "1" is replaced by "p", and outputs the result

5) The name of the corresponding variable value in accordance with "1" is divided, and outputs the result

6) The name becomes a variable value corresponding to upper case, and outputs the result

7) The name corresponding to the variable value becomes lower case, and the output

8) Please outputs of the two character values ​​corresponding to the variable name?

9) Please output the first three characters of the name value of the corresponding variable?

10) Please post the output value of two variables corresponding character name?

11) Request output value corresponding to the variable name index where "e" position?

12) acquisition sequences, removing the last - a character. Such as: oldboy then get oldbo

name=' a1eX'
print(name.strip())#1
print(name.startswith("a1"))#2
print(name.endswith("X"))#3
name1 = name.replace('1','p')
print(name1)#4
print(name.split('1'))#5
print(name.upper())#6
print(name.lower())#7
print(name[2])#8
print(name[0:3])#9
print(name[-2:])#10
print(name.find('e'))#11
print(name[:-1])#12

 

 

Guess you like

Origin www.cnblogs.com/crookedif/p/11080447.html