变量和数据类型 1.py
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了变量和数据类型 1.py相关的知识,希望对你有一定的参考价值。
name = "ada lovelace" #单词首字母大写 print(name.title()) name = "Ada Lovelace" #全部大写,全部小写 print(name.upper()) print(name.lower()) first_name = "ada" #字符串的拼接 last_name = "lovelace" full_name = first_name + " " + last_name print(full_name) print("python") print("\tpython") #制表符 print("Language:\npython\nC\nJavaScrite")#换行符 print("Language:\n\tpython\n\tC\n\tJavaScrite") favourite_language = ‘ python ‘ #删除空白 print(favourite_language.lstrip ()) print(favourite_language.rstrip ()) print(favourite_language.strip ()) message = "One of Python‘s strengths is its community" #引号应用 print(message) my_name = ‘zhangsan‘ #信息的输入 my_age = 26 my_height = 175 my_weight = 74 my_eyes = ‘blue‘ my_teeth = ‘white‘ my_hair = ‘black‘ print("Let‘s talk about %s."% my_name) print("He‘s %d inches tall."%my_height) print("He‘s %d pounds heavy."%my_weight) print("He‘s %s"%my_age) print("Actually that‘s not too heavy.") print("He‘s got %s eyes and %s hair."%(my_eyes,my_hair)) print("his teeth are usually %sdepending on the coffee."%my_teeth) print("if I add %d,%d,and %d Iget %d."%(my_age,my_height,my_weight,my_age+my_height+my_weight)) name = ‘ Eric‘ #字符串拼接 print( ‘hello‘+ name+ "would you like to learn some Python today") print("Hello %s would you like to learn some Python today "%name ) famous_sayings = ‘Albert Einstein once said,"A person who never made a mistake never tried anything new"‘ famous_person = ‘Albert Einstein‘ message = famous_person + ‘once said,"A person who never made a mistake never tried anything new"‘ print(message) age = 23 #整数作为字符串 message = ("Happy" + str(age) + "rd Birthday") print(message) age = ‘23‘ message = ("Happy" + age+ "rd Birthday") print(message) print(2+2) #数字的基本运算 print(2-2) print(2**2) print(2/2)
以上是关于变量和数据类型 1.py的主要内容,如果未能解决你的问题,请参考以下文章
Android 上的 Kotlin:如何在片段中使用数据库中的 LiveData?