#输入: print(help(input)) ''' input(prompt=None, /) Read a string from standard input. The trailing newline is stripped. The prompt string, if given, is printed to standard output without a trailing newline before reading input. If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError. On *nix systems, readline is used if available. None ''' name = input('请输入name:') #阻塞时 print(name) # input(promat=None)----->标准输入流(键盘) # input() 阻塞 类似管道(Linux中的|) # admin 回车结束阻塞状态----->将流中的内容输出----->赋值给name ''' 练习: 游戏:捕鱼达人 输入参与游戏者的用户名: 输入密码: 充值:500元 ''' print(''' *********************** 捕鱼达人 *********************** ''') username = input('请输入username:') password = input('请输入你的password:') print('{}请充值才能加入游戏!'.format(username)) coins = input('请充值:') # input() 输入的都是str,即使输入的是500,也会添加引号'500' coins = int(coins) #强转为int print('{}充值成功!当前游戏币是:{}'.format(username,coins)) ''' *********************** 捕鱼达人 *********************** 请输入username:小张 请输入你的password:python 小张请充值才能加入游戏! 请充值:500 小张充值成功!当前游戏币是:500 '''
Python 9
最新推荐文章于 2023-05-12 23:10:27 发布