简体   繁体   中英

In python, is there anyway to input a string without quotation marks?

我希望用户输入一个表的名称, table = str(input("table: "))可以工作,但是每次都输入'name'而不仅仅是name有点烦人,有什么解决办法吗?

Use raw_input :

table = raw_input("table: ")

>input([prompt])

Equivalent to eval(raw_input(prompt))

This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised. Other exceptions may be raised if there is an error during evaluation.

If the readline module was loaded, then input() will use it to provide elaborate line editing and history features.

Consider using the raw_input() function for general input from users.

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