python strip() 函数

strip()用于把左右两边的空格去掉,也可以在括号中指定去掉哪些字符 例如:\n

>>> sql = input("sql>")
sql>
>>> sql = input("sql>")
sql>   saddsa
>>>
>>> print(sql)  # 两边有空格
   saddsa
>>>
>>> sql = input("sql>").strip()
sql>   sadsads
>>> print(sql)   # 去掉左右两边空格
sadsads
>>>
 

猜你喜欢

转载自www.cnblogs.com/mingerlcm/p/8184434.html