The difference between raw_input and input in Python
- Raw_input The return result after getting the user input is a string type data
Gets the user input, converts to a string type, and then returns
(This figure is from document Python-2.7.6)
?
- Input gets the return value after the user input is a numeric type of data
Equivalent to Eval (raw_input (cue message))
(This figure is from document Python-2.7.6)
?
Connect to MySQL Database
Source :
Import MySQLdb #导入MySQLdb模块
print ' Connect database </br> '
#连接MySQL数据库 Connect the database
#Host If you fill out ' localhost ', error, please try to use ' 127.0.0.1 '
Db=mysqldb.connect (host= ' 127.0.0.1 ', user= ' root ', passwd= ' Michael ', db= ' test ')
#获取数据库游标 Get the database cursor
Cur=db.cursor ()
#执行SQL语句 Execute the SQL
R=cur.execute (' select * from people ')
#获取查询结果 get all the results selected
R=cur.fetchall ()
#输出查询结果
print ' Output database query result:</br> '
Print R
#关闭游标 Close the cursor
Cur.close ()
#关闭数据库连接 Close the database connection
Db.close ()
Python connects to MySQL database