python exit program gracefully

Discover python exit program gracefully, include the articles, news, trends, analysis and practical advice about python exit program gracefully on alibabacloud.com

Python Write Login Program

# 1. Login Program# username = ' Zhangmin '# Password = ' 123456 '# 2 Failures up to 3 times, failed 3 times program exit# If I ==3# Break # 3. Enter account number, password Error alert account, password error# 5. Enter the correct prompt Welcome to XXX LoginUsername = ' Zhangmin 'Password = ' 123456 'i = 0While True: user

A simple example of a Python program (communication)

to the standard output.Any number of the files can be specified.Options include:[1]: Search your friend ' s email from Friendsbook[2]: Add your friend ' s email to Firendsbook[3]: del your friend ' s email from Firnedsbook[4]: Alter your friend ' s email from Friendsbook[5]: All friends List[6]: Exit the program''' Num=raw_input (' Press the number [1,2,3,4,5]--') if (num== ' 1 '):Sname=raw_input (' Enter

Python tool program One, copy files with the extension specified in the directory

#!/usr/bin/env python# coding:utf-8# xcopy Lib directory and rename all files to *d.libimport osfrom os.path import join,e Xistsimport shutilfrom Win32com.shell Import shell, shellconfrom msvcrt Import Getchroot_path = r "E:\WORKSPACE\SRC" Origlibpath = Root_path + R "\vc\lib\lib18x64" Newlibpath = Root_path + R "\libd\lib18x64" if not EXISTS (Origlibpath): Prin T ("Can ' t find original libs!") Else:if os.path.exists (Newlibpath): Shutil.rmtree (Newl

Python Learning: Shopping Cart Program

Shopping Cart Procedureproduct_list = [(' Mac ', 9000),(' Kindle ',(' Tesla ', 900000),(' Python book ',(' bike ', '),]saving = input (' Please input your money: ')Shopping_car = []if Saving.isdigit (): #验证输入的是否为数字格式, if established then continuesaving = Int (saving)While True:#打印商品内容# for I in Product_list:# Print (Product_list.index (i), i)# for I in Enumerate (product_list,1):# Print (i)For i,v in Enumerate (product_list,1):print (i,v) #print (i, '

Python User Login Program

Requirements: Let the user enter the user name password Authentication successful display welcome information after the error three after the exit program can support multiple users logged in the user 3 times authentication failed, quit the program, restart the program when you try to log on, or lock the state#-*-codin

Python Shopping Cart Program first practice

Product_list = [(' Iphone ', 8000),(' Mac Pro ', 9800),(' Bike ', 800),(' Watch ', 10600),(' Coffee ', 30),]Shopping_list = []Salary = input ("Input your Salary:")If Salary.isdigit ():salary = Int (salary)While True:For Index,item in Enumerate (product_list):Print (Index,item)User_choice = input ("Choose to buy? >>>:")If User_choice.isdigit ():user_choice = Int (user_choice)If User_choice P_item = Product_list[user_choice]If P_ITEM[1] Shopping_list.append (P_item)Salary-= p_item[1]Print ("Your C

Python beginner 13th Day Level Three menu program small job

13dayJob Title: Level Three menuJob Requirements: data structure: Menu = {' Beijing ': {' Haidian ': {' Five crossings ': {' Soho ': {}, ' NetEase ': {}, ' Google ': {}}, ' Zhongguancun ': {' Iqiyi ': {}, ' Autohome ': {}, ' Youku ': {},}, ' on the ground ': {' Baidu ': {},},}, ' Changping ': { ' Shahe ': {' old boy ': {}, ' Beihang ': {},}, ' Tian Tong Yuan ': {}, ' Huilongguan ': {}, }, ' Chaoyang ': {}, ' Dongcheng ': {},}, ' Shanghai ': {' Minhang

C++/php/python/shell program reads files by line or console

file1PHP2 $filename= "Input_file_name";3 4 $fp=fopen($filename, "R");5 if(!$fp){6 EchoThe Open File$filenamefailed\n ";7 Exit(1);8 }9 Else{Ten while(!feof($fp)){ One //fgets (file,length) does not specify a length of 1024 bytes by default A $buf=fgets($fp); - - $buf=Trim($buf); the if(Empty($buf)){ - Continue; - } - Else{ + Echo $buf." \ n "; - } + } A

Total Pages: 9 1 .... 5 6 7 8 9 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.