Python学习笔记-打印与输入

1.单行注释:#
多行注释用三个单引号’
2.打印单引号与双引号:\’ \”
3.重复打印
print("."*10) #可输出10个.
4.formatter使用

formatter="%r %r %r %r"         
print(formatter%(1,2,3,4))  
print(formatter%("one","two","three","four"))
输出为:
1 2 3 4 
'one' 'two' 'three' 'tour'

5.一组三个双引号之间可以放任意多行文字

print("""
one
two
three
""")

'''
输出为
one
two
three
'''

6.\t相当于一个tab键
7.格式化字符串%r与%s的区别
%r是将文本内容全部输出
%s是将应该看到的东西打印输出

persian_cat="I'm split\non a line."
print("%r"%persian_cat)
print("%s"%persian_cat)
输出为:
"I'm split\non a line."
I'm split
on a line.

8.字符串连接
+为无缝连接
以逗号连接在打印时以空格代替

end1="C"
end2="h"
end3="e"
end4="e"
end5="s"
end6="e"
print(end1+end2+end3+end4+end5+end6)
print(end1,end2,end3,end4,end5,end6)
输出为:
Cheese
C h e e s e

9.input()函数使用

print("How old are you?")
age=input()

或者

age=input("How old are you?")

你可能感兴趣的:(学习笔记)