Make file 换行符(反斜杠\)的用法


all :
	@for subdir in $(SUBDIRS);\
    do $(MAKE) -C $(DIR)/$$subdir || exit 1;\
    done

如上,

  1. 末尾加“\”
  2. 第二行前不得为tab键,空格即可

希望对大家有帮助。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在QPainter中,可以使用Python原生字符串(使用反斜杠\作为转义字符)来处理反斜杠换行符\,例如: ```python text = "This is a multi-line text. "\ "It spans over multiple lines." ``` 这将被解释为单个字符串,不包括反斜杠换行符。 如果您的文本包含反斜杠换行符,并希望在绘图期间处理它们,则可以使用Python的字符串处理方法。例如,可以使用split()方法将字符串分成多行,然后使用嵌套的循环来逐行绘制文本。 以下是一个示例代码,可以处理反斜杠换行符: ```python from PyQt5.QtGui import QPainter # ... def paintEvent(self, event): painter = QPainter(self) font = painter.font() font.setPointSize(14) painter.setFont(font) text = "This is a multi-line text. "\ "It spans over multiple lines. "\ "This is the third line.\n"\ "This is the fourth line." rect = self.geometry() top_margin = 20 bottom_margin = 20 left_margin = 20 right_margin = 20 lines = text.split('\n') y = top_margin for line in lines: x = left_margin words = line.split() for i, word in enumerate(words): if i > 0: x += painter.fontMetrics().width(' ') if '\n' in word: word, sep = word.split('\n') painter.drawText(x, y, word) y += painter.fontMetrics().height() x = left_margin painter.drawText(x, y, sep) else: word_width = painter.fontMetrics().width(word) if x + word_width > rect.width() - right_margin: x = left_margin y += painter.fontMetrics().height() painter.drawText(x, y, word) x += word_width y += painter.fontMetrics().height() painter.end() ``` 在此示例中,我们首先将文本分成多行,然后使用嵌套的循环逐行绘制文本。在每行中,我们使用split()方法将单词分开,并在必要时处理反斜杠换行符。如果单词中包含换行符,则我们使用split()方法将其分成两部分,并在第一部分中绘制文本,然后在下一行中绘制第二部分。否则,我们计算单词的宽度,并在达到行末时换行。 请注意,此示例仅处理换行符,而不考虑其他反斜杠转义序列。如果您的文本包含其他反斜杠转义序列,例如\t或\r,则需要对代码进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

debug狂魔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值