Learning Python fourth day job

# Job ideas: how to choose the right type of record status? ? ?
# 1, state whether the selected type can clearly identify things of
# 2, deposit is not an end, the purpose of existence is to later be taken out with, and easy to use
# 3, to think of myself as a computer, if I were a computer,
# how and in what form I will be the state of things in mind to mind
# and then find the appropriate data type to let the computer go in python like herself to remember the state of things
# ps: read the questions carefully, needs its own title from analysis of the state should be stored, and then select the appropriate type to be stored

# 1, the virus needs to periodically monitor the program data is written to the log file, the log file records the path C: \ a \ b \ c \ adhsvc.dll.system32, easy post-processing
string: log_path = r'C : \ a \ b \ c \ adhsvc.dll.system32, '# r' '---> the Read

# 2, the virus program when you upload a file, the data sent in a header file contains the required information: file name a.txt, size 360, record the file information
program using a dictionary: header_info = { 'filename': 'locked.txt', 'size': 360}
the second scheme, the string:
file_name = 'a.txt'
FILE_SIZE = 300

#. 3 , the program is running there is a need to record an error log, an error log is "upload file failed"
log = "upload failed" error log string
log_list = [ 'log 1', '2 log'] # multiple error logs using the list

# 4, assuming I get a message to be recorded, the information is information virus client "[2020-02-18-17: 00: 48] toad with HIV -> 80.82.70.187:33649 uploading data "
string: virus_client_info =" [2020-02-18-17: 00 : 48] toad HIV - > 80.82.70.187:33649 Uploading data "

# 5, the ip address storage server down, 10.0.10.11 ip address
string: server_address = '10 .0.10.11 '

# 6, the virus program need only run once every 3 seconds, record the time interval that
the integer: time_interval = 3


# II: Nested operation value
# 1, students_info = [[ ' egon', 18, [ 'play',]], [ 'alex', 18, [ 'play', 'sleep']]]
Remove section a first-loving students
Option one:
Print (students_info [0] [2] [0]) -> Play
Option two:
Print (students_info [0] [- 1] [0]) -> Play
# 2, for the dictionary
info = {
'name': 'Egon',
'hobbies': [ 'Play', 'SLEEP'],
'company_info': {
'name': 'Oldboy',
'type': 'Education',
'emp_num': 40,
}
}
remove take company name
print (info [ 'company_info'] [ 'name']) -> Oldboy

# 3, the following type for
Students. = [
{ 'Name': 'Alex', 'Age': 38 is, 'hobbies': [' Play ',' SLEEP ']},
{' name ':' Egon ',' Age ': 18 is,' hobbies ': [' Read ',' SLEEP ']},
{' name ':' wupeiqi ',' Age ': 58,' hobbies ': [' Music ',' Read ',' SLEEP ']}
]
take the second student is interested in a second
embodiment a:
Print (students. [. 1] [' hobbies'] [. 1]) -> SLEEP
scheme II:
Print (students. [. 1] [ 'hobbies' ] [- 1]) -> sleep

Guess you like

Origin www.cnblogs.com/liunaixu/p/12411392.html