Python常见编写问题和提醒
2019-09-29 本文已影响0人
SoundYoung
1,PyCharm中warning: no newline at end of file
解决办法:代码末端添加回车
2,Pycharm中光标变粗,不可输入
tool-->vim emulator去掉前面的✔️
3,shadows built-in “变量名”
type = "xxxx" 就会报提醒
如果下面这样写就不会
type_one = "xxxxxx"
4,excepted 2 blank lines after class or function
原因是方法或者类后面的代码 要离方法体或者类之间有两个回车
报提醒:
def demo(obj):#type_one 变量距离上面的demo方法只有一个回车
print(obj)
type_one = "xxxx"
demo(type_one)
不报提醒:
def demo(obj):#type_one 变量距离上面的demo方法有两个个回车
print(obj)
type_one = "xxxx"
demo(type_one)
5,continuation line over-indented for visual indent
按删除,保持第二行跟第一行的开始对其
sql = 'INSERT INTO STATIONS ( name , py) VALUES (%s, %s ) ' %
("'"+name_value+"'", "'"+py_value+"'")
上面这样就不会有提示
如果
sql = 'INSERT INTO STATIONS ( name , py) VALUES (%s, %s ) ' %
("'"+name_value+"'", "'"+py_value+"'")
就会提示