Interestingly, if you're using gfortran, you can use the option -fbackslash while compiling to use C-style backslashing, as mentioned in the documentation:-反斜杠将字符串文字中反斜杠的解释从单个反斜杠字符更改为"C样式"转义字符.以下组合将\ a,\ b,\ f,\ n,\ r,\ t,\ v,\和\ 0扩展为ASCII字符警报,退格键,换页符,换行符,回车符,水平制表符,垂直制表符,反斜杠和NUL.此外,\ xnn,\ unnnn和\ Unnnnnnnn(其中每个n是十六进制数字)被转换为与指定代码点相对应的Unicode字符.所有其他以\开头的字符组合都不会扩展.Change the interpretation of backslashes in string literals from a single backslash character to "C-style" escape characters. The following combinations are expanded \a, \b, \f, \n, \r, \t, \v, \, and \0 to the ASCII characters alert, backspace, form feed, newline, carriage return, horizontal tab, vertical tab, backslash, and NUL, respectively. Additionally, \xnn, \unnnn and \Unnnnnnnn (where each n is a hexadecimal digit) are translated into the Unicode characters corresponding to the specified code points. All other combinations of a character preceded by \ are unexpanded.因此,字符串将简化为str = "First\nSecond" 这篇关于字符串文字中的转义序列(Fortran)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-06 02:29