编程札记

P

Python3 字符串String Count 方法

Python3 字符串String Count 方法 #!/usr/bin/python3 str = "this is string example....wow!!!" sub = 'i' print ("str.count('i') : ", str.count(sub)) sub = 'exam' print ("str.count('exam', 10, 40) : ", str.count(sub,10,40))

阅读全文 ↗
P

Python3 三引号

Python3 三引号 #!/usr/bin/python3 para_str = """this is a long string that is made up of several lines and non-printable characters such as TAB ( \t ) and they will show up that way when displayed. NEWLINEs within the string, whether explicitly given like this within the brackets [ \n ], or just a NEWLINE within the variable assignment will also show up. """ print (para_str)

阅读全文 ↗
P

Python3 数字Number Radian 方法

Python3 数字Number Radian 方法 #!/usr/bin/python3 import math print ("radians(3) : ", math.radians(3)) print ("radians(-3) : ", math.radians(-3)) print ("radians(0) : ", math.radians(0)) print ("radians(math.pi) : ", math.radians(math.pi)) print ("radians(math.pi/2) : ", math.radians(math.pi/2)) print ("radians(math.pi/4) : ", math.radians(math.pi/4))

阅读全文 ↗
P

Python3 数字Number Degrees

Python3 数字Number Degrees #!/usr/bin/python3 import math print ("degrees(3) : ", math.degrees(3)) print ("degrees(-3) : ", math.degrees(-3)) print ("degrees(0) : ", math.degrees(0)) print ("degrees(math.pi) : ", math.degrees(math.pi)) print ("degrees(math.pi/2) : ", math.degrees(math.pi/2)) print ("degrees(math.pi/4) : ", math.degrees(math.pi/4))

阅读全文 ↗
P

Python3 数字Number Tan 方法

Python3 数字Number Tan 方法 #!/usr/bin/python3 import math print ("(tan(3) : ", math.tan(3)) print ("tan(-3) : ", math.tan(-3)) print ("tan(0) : ", math.tan(0)) print ("tan(math.pi) : ", math.tan(math.pi)) print ("tan(math.pi/2) : ", math.tan(math.pi/2)) print ("tan(math.pi/4) : ", math.tan(math.pi/4))

阅读全文 ↗