前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python 第2天

python 第2天

作者头像
py3study
发布2020-01-11 22:13:09
6510
发布2020-01-11 22:13:09
举报
文章被收录于专栏:python3python3

import easygui,random

secret = random.randint(1,99)

easygui.msgbox("""I have a secret ,It is a number from 1-99 ,you have 6 tries

.OK let'do it.""")

tries=0

guess=0

while tries < 6 and guess != secret:

? ? guess = easygui.integerbox("what's your guess,metey?") ?

//只允许输整数,若是小数可以用 guess = float(easygui.enterbox("what's your guess,metey?"))

? ? if not guess: break

? ? if guess < secret:

easygui.msgbox(str(guess)+"is too low !")

? ? elif guess > secret:

? ? ? ? easygui.msgbox(str(guess)+"is too high,landlubber!")

? ? tries = tries + 1

if guess == secret:

? ? easygui.msgbox("you got it,congratulate")

else:

? ? easygui.msgbox("No more chance.my secret is "+str(secret),"Test")

注意,easygui.msgbox 对应到目录中是/lib/easygui/__init__.py 中的

这是__init__.py中的内容

__all__ = ['buttonbox',

? ? ? ? ? ?'diropenbox',

? ? ? ? ? ?'fileopenbox',

? ? ? ? ? ?'filesavebox',

? ? ? ? ? ?'textbox',

? ? ? ? ? ?'ynbox',

? ? ? ? ? ?'ccbox',

? ? ? ? ? ?'boolbox',

? ? ? ? ? ?'indexbox',

'msgbox',

? ? ? ? ? ?'integerbox',

? ? ? ? ? ?'multenterbox',

? ? ? ? ? ?'enterbox',

? ? ? ? ? ?'exceptionbox',

? ? ? ? ? ?'choicebox',

? ? ? ? ? ?'codebox',

? ? ? ? ? ?'passwordbox',

? ? ? ? ? ?'multpasswordbox',

? ? ? ? ? ?'multchoicebox',

? ? ? ? ? ?'EgStore',

? ? ? ? ? ?'eg_version',

? ? ? ? ? ?'egversion',

? ? ? ? ? ?'abouteasygui',

? ? ? ? ? ?'egdemo',

]

# Import all functions that form the API

from .boxes.button_box import buttonbox

from .boxes.diropen_box import diropenbox

from .boxes.fileopen_box import fileopenbox

from .boxes.filesave_box import filesavebox

from .boxes.text_box import textbox

from .boxes.derived_boxes import ynbox

from .boxes.derived_boxes import ccbox

from .boxes.derived_boxes import boolbox

from .boxes.derived_boxes import indexbox

from .boxes.derived_boxes import msgbox ??

//这里真实的目录就是 安装路径/Lib/boxes/derived_boxes

from .boxes.derived_boxes import integerbox

from .boxes.multi_fillable_box import multenterbox

from .boxes.derived_boxes import enterbox

from .boxes.derived_boxes import exceptionbox

from .boxes.choice_box import choicebox

from .boxes.derived_boxes import codebox

from .boxes.derived_boxes import passwordbox

from .boxes.multi_fillable_box import multpasswordbox

from .boxes.choice_box import multchoicebox

from .boxes.egstore import EgStore, read_or_create_settings

from .boxes.about import eg_version, egversion, abouteasygui

from .boxes.demo import easygui_demo as egdemo

msgbox(msg="(Your message goes here)", title=" ",

? ? ? ? ? ?ok_button="OK", p_w_picpath=None, root=None): 使用格式。

easygui.msgbox("""I have a secret ,It is a number from 1-99 ,you have 6 tries

.OK let'do it.""","Test","YES","D:/picture/2.gif") //是使用事例

使用效果如图

wKioL1m0nP3Rh1l0AACObKVg8JY729.jpg-wh_50
wKioL1m0nP3Rh1l0AACObKVg8JY729.jpg-wh_50

import easygui

name = easygui.enterbox("what's your name?")

room_num = easygui.enterbox("what's your room number?")

street_num = easygui.enterbox("what's your street name?")

city = easygui.enterbox("what's your city?")

province = easygui.enterbox("what's your province?")

country = easygui.enterbox("what's your country?")

easygui.msgbox("name="+name+"\r\n"+"room_num="+room_num+"\r\n"+"street_num"+street_num+"\r\n"+"city"+city+

? ? ? ? ? ? ? ?"\r\n"+"province"+province+"\r\n"+"country"+country)

"\r\n" 换行显示的关键,若是linux系统中是"\n".?

for looper in range(1,5):

print (looper)

注意这里只会打印出1,2,3,4

for looper in range(1,10,2): //这里的步长为2.从1,10.当然步长也可以为负数/

print (looper)

//小的倒计时器

import time

for i in range(10,0,-1):

? ? print (i)

? ? time.sleep(1)

print ("BLASH OFF!")

for i in ["jixaing"]: #注意与下面的区别 按字符串算一个

? ? print (i+"is coolest guy!")

for i in "jixaing": #按字符输出多个

? ? print (i+"is coolest guy!")

本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-08-15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com