如何在Python中使用字符串【每日一個(gè)知識(shí)點(diǎn)第352期-Python】
a、使用單引號(hào)(‘)
用單引號(hào)括起來(lái)表示字符串,例如:
str=’this is string’;
print str;
b、使用雙引號(hào)(“)
雙引號(hào)中的字符串與單引號(hào)中的字符串用法完全相同,例如:
str=”this is string”;
print str;
c、使用三引號(hào)(”’)
利用三引號(hào),表示多行的字符串,可以在三引號(hào)中自由的使用單引號(hào)和雙引號(hào),例如:
str=”’this is string
this is pythod string
this is string”’
print str;