Mind Mapping "Annotations"1. Control flow Statements 1.1 Article statement [execute code block according to condition]1.1.1 If statement1.1.2 Else Statement1.1.3 ElseIf Statements[DEMO] (When conditions are large, note the order of the conditions) 1.2 Loop statements1.2.1 While loop statement1.2.2 For Loop statement1.2.3 Break statement1.2.4 Continue statements[DEMO] (while and for loops can be used equivalently) 2. Importing the module method [DEMO]3. Function parsing[DEMO]
1#!/usr/bin/env python3.52#Coding:utf-83#5.6.14#List of items for fun games5#given a dictionary that contains the item name and quantity, and prints out the quantity corresponding to the item6 7 Dict_stuff = {'Rope': 1,'Torch': 6,'Gold coin': 42,'Dagger': 1,'Arrow': 12} 8Print("5.6.1 Reference Answers") 9Print('='* 80) 10Print("Given dictionary:", Dict_stuff)11Print("Operation Result:") 12defDisplayinventory (Inventory):13Print("Inventory:") Item_total =015 forKvinchInventory.items ():16Print(
method, because the column length of the list is not equal, the outer loop of the number of newline should be the length of the child List. the forRowinchRange (0,len (grid[0)): * forColinchRange (0,len (grid)): $ #print (". join (grid[col][row]), End=")Panax Notoginseng Print(grid[col][row],end="') - Print() the + #the second method of implementation, a forRowinchZip (*grid): the forColinchRow: + #print (". join (col), End=") - Print(col,end="') $ Print()
First.txtThe adjective Panada walked to the NOUN and then VERB. AnerbyNOUN was unaffected by these events.#!python3#-*- coding:utf-8 -*-#8.9.2疯狂填词游戏#用户自定义词语,修改打开文件中的ADJECTIVE、NOUN、VERBimport ref=open(‘first.txt‘,‘r+‘)files=f.read()print(files)f.close()changelist=[‘ADJECTIVE‘,‘NOUN‘,‘VERB‘]for i in changelist: change_reg=re.compile(r‘%s‘ % i) text=input("Enter a %s :" % i) files=change_reg.sub(text,files)fi_2=open(‘third.txt‘,‘w‘)fi_2.write(files)fi_2.close()"
#-*-coding:utf-8-*-# The required output is as follows:# apples Alice Dogs# dranges Bob Cats# cherries Carol Moose# banana David Goose tabledata=[[' apples ',' oranges ',' cherries ',' banana '],[' Alice ',' Bob ',' Carol ',' David '],[' Dogs ',' Cats ',' Moose',' goose '] def printtable(data): colwidths=[0]*len(data)For y in range(len(data[0])):For x in range(len(data)): if colwidths[x] Len(data[x] [y ]): colwidths[x]=len(data[x] [y]) For y in range(len(data[0])):For x in ra
Let me briefly introduce the two commonly used data structures, series and daraframe in Python, which are defined by the Pandas module. The series is similar to dict in Python, but is structured, and dataframe is similar to a table in a database.1.pandas basic data Structure-pandas. Seriespandas. DataFramethe second method of defining Dataframe cannot set index manually, only the sequence can be generated a
typeAn ordered collection of arbitrary objects, which are accessed through an index, immutable objects, fixed lengthsSupports heterogeneous, nestedCommon operations:()(1,)(from)T1 + T2T1 * NInNot in:Although the tuple itself is immutable, modifications to such elements do not return tuples if they are nested inside a mutable type elementDictionary: DictDictionaries are also referred to as associative arrays or hash lists in other programming languageselement access by key, unordered set, mutabl
#!python3#9.8.1#遍历目录树,查找特定扩展名的文件(自定义)#and把查找到的文件,copy到新文件夹import os,shutilfile_dir=input("输入要查找的目录:")file_dir=os.path.abspath(file_dir)file_list=[]if not os.path.exists(file_dir): print("目录不存在")else: file_type=input("输入要查找文件类型的扩展名(如.pdf或.jpg):") file_type=file_type.lower() for folder,subfolders,files in os.walk(file_dir): for fi in files: if fi.lower().endswith(file_type): file_list.append( os.path.join(folder,fi))#复制destination=input("输入要存放文件的目录:")destination=os.path.abspath(destination)if not
Saltstack Quick Start summary and saltstack Quick Start
Saltstack is an open-source automated deployment and management tool written in python. It has good scalability and excellent execution efficiency, simple configuration, and can work on multiple platforms, it is often d
Quick Start to some basic functions of Nginx and quick start to basic functions of nginx
This article mainly introduces some basic functions and simple configurations of Nginx, but does not include the installation, deployment, and implementation principles of Nginx. Not much nonsense.
IOS 7 UI Transition Guide-Before getting started (iOS 7 UI Transition Guide-Before You Start)
IOS 7 UI Transition Guide
Preparing for Transition
Before You Start
Scoping the Project
Supporting iOS 6
Updating the UI
Appearance and Behav
Python function Programming Guide (4): generator details, python programming guide
4. generator)
4.1. Introduction to generators
First, be sure that the generator is an iterator. The generator has the next method and has the same behavior as the iterator, which means that the generator can also be used in a
Python function Programming Guide (3): iterator details, python programming guide
3. iterator
3.1. Iterator Overview
An iterator is a way to access elements in a set. The iterator object is accessed from the first element of the set until all elements are accessed.
The iterator cannot be rolled back and can only be ite
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.