%转义

select * from info_detail_preissue t
where t.info_title like '%/%%' escape '/';

### % 转义字符的含义 在不同的编程语言中,`%` 字符有不同的含义和作用。在 Python 中,`%` 本身不是传统意义上的转义字符,但它在字符串格式化中有重要作用,被用作格式化操作符。在 C 语言等其他语言中,`%` 同样在格式化输出函数(如 `printf`)中用于指定输出格式。 ### % 转义字符的用法 #### Python 中的用法 在 Python 中,`%` 用于字符串格式化。以下是一些常见的用法示例: ```python # 格式化整数 num = 10 print("The number is %d" % num) # 格式化浮点数 pi = 3.14159 print("The value of pi is %.2f" % pi) # 格式化字符串 name = "Alice" print("Hello, %s!" % name) # 多个变量格式化 age = 25 print("%s is %d years old." % (name, age)) ``` 如果要在字符串中表示 `%` 字符本身,需要使用两个 `%%` 进行转义: ```python print("The discount is 10%%.") ``` #### C 语言中的用法 在 C 语言中,`%` 在 `printf` 等函数中用于格式化输出。例如: ```c #include <stdio.h> int main() { int num = 20; float price = 9.99; char str[] = "World"; printf("The number is %d\n", num); printf("The price is %.2f\n", price); printf("Hello, %s!\n", str); return 0; } ``` 同样,要输出 `%` 字符本身,需要使用 `%%`: ```c #include <stdio.h> int main() { printf("The tax rate is 5%%.\n"); return 0; } ``` ### 相关知识 `%` 字符在字符串格式化中,后面通常会跟一个格式化说明符,不同的说明符用于不同的数据类型和输出格式。常见的格式化说明符包括: - `%d`:用于格式化整数。 - `%f`:用于格式化浮点数。 - `%s`:用于格式化字符串。 - `%c`:用于格式化单个字符。 在 Python 中,除了 `%` 格式化,还有更现代的 `str.format()` 方法和 f-string 语法用于字符串格式化,但 `%` 格式化仍然在一些旧代码和特定场景中使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值