简体   繁体   中英

Using raw_input() without assigning a variable

I've only recently begun learning python2, and this is the way I see raw_input() .

If suppose I write name = raw_input("What's your name? ") then I ask the user to enter something which gets stored as a string assigned to the variable name . By assigning it to name , I can use it for whatever purpose I needed it later.

But what does using raw_input() without assigning the input to a variable accomplish? Also pressing enter at this point is supposed to continue with the script (so I have deduced, am I right?), but where is this behaviour documented? In what kind of a situation would I use raw_input() without assigning to a variable? I couldn't find my answers in the official python documentation. http://docs.python.org/2/library/functions.html#raw_input

THanks

For debugging purposes you may just want your code to pause for a second so you can analyse some print statements describing what's happening in your code. There's really not set reason for having this, it's up to you.

raw_input()可以与int()一起使用,以根据用户选择的内容设置循环的长度,而无需声明变量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM