当前位置:网站首页>第一章第九节:最简单的用户交互
第一章第九节:最简单的用户交互
2022-07-20 10:10:00 【中亿丰数字科技有限公司】
Python基础入门(全套保姆级教程)
第一章
第九节:最简单的用户交互
我们经常使用的程序都会有与用户交互的程序,比如网页的登录,需要输入自己的账号,密码这类的用户交互功能。我们来写个简单的用户输入和输出的程序代码:
照着做体验一下
用户登录
username = input('请输入你的用户名:')
password = input('请输入你的密码:')
print(int(username))
print(int(password))
计算器
a = input("请输入第一个数字:")
# print(type(a)) # 用type来查看一个变量的数据类型
b = input("请输入第二个数字:")
a = int(a)
b = int(b)
print(a + b)
总结:
变量 = input(提示语)
首先会在屏幕中显示出提示语, 用户输入内容. 然后把用户输入的内容交给前面的变量
坑: input()得到的结果一定是字符串
怎么把字符串转化成数字类型
py基础数据类型:
想把xxx转化成谁, 就用谁套起来
str => int int(str)
边栏推荐
猜你喜欢
随机推荐
[dark horse morning post] musk: I have uploaded my brain to the cloud; ByteDance confirms the self-developed chip; Luo min of qudian said that she was blackmailed by Dong Yuhui selected by Dongfang; C
C# DataGridView数据导出Excel文件
云原生平台,让边缘应用玩出花!
Ankerui motor monitoring scheme low voltage motor circuit and feeder distribution circuit power energy monitoring
[020] [stm32] analysis and application of CAN bus communication protocol
语雀—好用的文档编写、知识沉淀的工具
Sys_ RMAN backup error
数商云:如何实现供应商SRM管理系统的应用价值?
Redis-命令行客户端
[问题已处理]-mysql使用同一个yaml使用nfs共享存储报错
SAP Spartacus 如何根据 page layout 获得对应支持的 slots
ASP.NET Core 6框架揭秘实例演示[01]: 编程初体验
Learning records [email protected] Moveexecutionstosingleactivityid parallel gateway or inclusive gateway fallback
APK打包流程
【u-boot】u-boot运行主线分析【02】—board_init_f
安科瑞马达监控方案低压电动机回路及馈线配电回路电力能源监测
ogg 抽取数据延时大
【u-boot】u-boot运行主线分析【01】—_main
node卸载
R语言使用逻辑回归Logistic、单因素方差分析anova、异常点分析和可视化分类iris鸢尾花数据集