python-3.x - 如何在 print() 字符串中嵌入变量,然后在 python 3.9 中调用函数
问题描述
我正在研究需要用户输入他们的名字的python代码,理论上它工作得很好,但是当我运行脚本时,我得到这3行作为输出:
Please Enter your name
Your name will be saved as, <built-in function input>
这是代码:
# Function for the user's name and then sends user to menu
print("Please Enter your name\n")
name = input
print("Your name will be saved as, ", name,)
menu()
解决方案
线。名称=输入。保存什么是函数“输入”你需要以正确的方式使用函数“输入”
# Function for the user's name and then sends user to menu
print("Please Enter your name\n")
name = input()
print("Your name will be saved as, ", name,)
menu()
推荐阅读
- c# - 创建从服务器上的 URL 获取的 Image 的 LinkedResource
- c# - 如果我使用内部,Couchbase 会将空内容插入服务器,为什么?
- typescript - 打字稿 - 为什么通用字典类型不返回可能未定义的值?
- javascript - 如何在 JS 中将键值搜索到多维数组中?
- tableau-api - 在画面中追加列
- tomcat - 如何将“Referrer-Policy”和“Feature-Policy”标头添加到 Jira 8 的 Tomcat
- sql - 我可以逐行编写数据库查询的结果并跳过 Python 3 中的数据帧吗?
- postgresql - K8S使用volume来保存DB数据
- gdb - 为什么 GDB 会更改给定地址中的内容?
- vuetify.js - 如何在 Vuetify 2.0.5 中设置 v-sheet/v-container 大小以匹配屏幕与 v-app-bar?