[英]How to I combine the output of 2 print statements to a single line in Python?
[英]Can I combine if and with statements in a single line?
我有一個代碼塊如下:
if condition:
with something as another_thing:
// do my stuff here
由於有多個縮進,我不喜歡這種風格。 我可以以某種方式將 if 和 with 語句組合在一行中,並減少縮進嗎?
你不能,但你可以在同一行放置多個語句。 你可以在這里閱讀更多關於它的信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.