简体   繁体   English

如何从用户那里获取输入,将其存储在一个空变量中并打印该变量?

[英]How do I take input from a user, store it in an empty variable and print the variable?

Here is my code:这是我的代码:

name = ' '

Nameval = name("Enter the victims IP address: ")

print("Hello, " + name)

I want this code to take the input from Nameval, store it in the "name" variable and then print the name variable.我希望此代码从 Nameval 获取输入,将其存储在“name”变量中,然后打印 name 变量。 However, it wont work.但是,它不会工作。 How can I do this?我怎样才能做到这一点?

You need to use input([prompt]) .您需要使用input([prompt])

name = input("Enter the victims IP address: ")

print("Hello, " + name)

Your code is wrong.你的代码是错误的。 You are not asking for an input, try this.你不是要求输入,试试这个。

name = input('Enter IP address: ')
print(f'Hello {name}')

F string are better than concatination F 字符串优于连接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 discord 获取用户输入并将其存储为变量以在方程式中使用? Discord.py - How do i take user input from discord and store it as a variable to use in an equation? Discord.py 如何将输入的一部分作为变量? - How do I take part of an input as a variable? 如何存储从用户输入创建的变量并在 Python 的不同文件中使用它? - How do I store a variable that has been created from a user input and use it in a different file in Python? 如何在 python 中将多个文件作为输入并存储在变量中 - How can I take multiple file as input in python & store in a variable 如何从用户输入的另一个变量中查找单词? - How do i find a word from user input in another variable? 如何从列表中取出特定数据并存储在单个变量中 - How do i take out specific data from my list and store in a individual variable 如何打印QLineEdit的输入/存储在变量中? - How to print input of QLineEdit/ store in variable? 在使用 pytest 的整个测试过程中,如何将用户的 function 作为测试变量? - How do I take a function from a user as a test variable throughout the testing with pytest? 如何让itemgetter从列表变量中获取输入? - How can I make itemgetter to take input from list variable? 如何从用户输入中读取多个(可变长度)参数并将其存储在变量中并将其传递给函数 - How can I read multiple (variable length) arguments from user input and store in variables and pass it to functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM