對比學習Python與Cstr1 = 'hello python 2'# 字元串i = 3.1415926535print(str1)print("hello python\n")# print 自帶換行符print('%s'%str1)print(str1)print("你好,%s OK %d" ... ...
對比學習Python與C
str1 = 'hello python 2'
# 字元串
i = 3.1415926535
print(str1)
print("hello python\n")
# print 自帶換行符
print('%s'%str1)
print(str1)
print("你好,%s OK %d" % (str1, i))
##格式化列印到標準輸出
print("%.2f\t%.4f" % (i, i))
輸出:
hello python 2
hello python
hello python 2
hello python 2
你好,hello python 2 OK 3
3.14 3.1416