pycharm使用技巧-换行

python脚本有时一行代码写的非常长,一个屏幕塞不下,左右拉动滚动条视觉不友好。

第一种方法:

python里有换行标识"\",如

jfdb=spark.read.format("jdbc").option("driver", mysql_driver).option("url", mysql_url).option("dbtable", "xxxxxxxxxxxxxxxxxxxxxxxx").option("user", mysql_acount).option("password", mysql_password).load().where("bank='1234' ").select("col1").rdd.collect()[0]['col1']

太长,我们可以写成如下形式

jfdb=spark.read.format("jdbc").option("driver", mysql_driver).option("url", mysql_url)\
.option("dbtable", "tableName").option("user", mysql_acount).option("password", mysql_password).load()\
.where("bank='1234' ").select("col1").rdd.collect()[0]['col1']

第二种方法

设置pycharm自动换行。
点击file -> settings -> Editor -> General -> Soft Wraps
勾选
在这里插入图片描述
可以选择自动换行的文件类型。
最后效果如图
在这里插入图片描述
自动换行的地方有个回转的小箭头,代表跟上一行其实是属于同一行。这样就不需要拉滚动条看全部的代码了。

Supongo que te gusta

Origin blog.csdn.net/nanfeizhenkuangou/article/details/119790766
Recomendado
Clasificación