python - Python中的隐含字符串连接
问题描述
我注意到当我像这样换行时,Pylance 没有给我一个错误:
>>> print('foo bar'
... ' and then some.')
foo bar and then some.
我试过了,Python 似乎很乐意将这些连接起来,而且很简单:
>>> print('foo bar' 'and more')
foo barand more
我想我需要一个+
来连接。这种行为是否可靠,或者我应该+
用于换行,例如:
print('This is '
+ 'more readable.')
谢谢
解决方案
推荐阅读
- r - 读取具有随机数量空格的文件
- angular - Angular 12 HttpClient POST 到字符串无法编译
- matlab - 加载和绘制矩阵的 Matlab 错误
- javascript - 将属性从对象分配给 HTMLElement 的 es6/7 简写
- laravel - laravel voyager 多显示关系
- javascript - 使用 webpack 将 20 多个入口点转换为 1 个或几个
- node.js - POST 请求失败,无法登录
- wso2 - WSO2 身份服务器 - 如何以编程方式更新密码历史设置
- sails.js - Sails.JS 模型无法全局访问,即使 Globals.JS 包含模型:从 0.12 升级到 1.4.3 后的 true
- python - 从 Python 3 中的嵌套文件夹导入库