问题
I'm just starting out on Fortran and am confused with the usage of double vs single quotation marks.
回答1:
They are equivalent. There is no difference in their usage.
You can employ this to print one of the quotation characters:
print *, "'"
print *, '"'
prints first ' and then ".
Note: You can also use two quote characters in a row to print one:
print *, """"
print *, ''''
prints first " and then '.
回答2:
Functionally they have no difference. Just try to be consistent about which one you use. If your strings tend to have double quotes in them, use single quotes everywhere; if you use single quotes more often, use double quotes to delimit your strings.
As an additional note, it is possible to escape the quote character inside a string: (i.e. 'You\'re') but most people would suggest using it doubled up as they would find it more readable (i.e. 'You''re').
来源:https://stackoverflow.com/questions/30997887/difference-between-double-and-single-quotation-marks-in-fortran