我想将格式化的字符串分配给变量。例如,我将在Python中编写以下代码:
my_score = 100
line = "score = %d" % my_score
print(line)
这将打印以下内容:
score = 100
如何在Fortran中编写相同的内容?
答案 0 :(得分:0)
您的代码的直接实现类似于:
program test
implicit none
integer :: score
character(len=30) :: line
score = 100
write(line, '(A,I3)') "score = ", score
write(*,'(A)') line
end program test