python_day01_字符类型

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_37361758/article/details/83096328
  • 变量 命名规则:
    • ①驼峰体
      AgeOfOldboy = 56
      NumberOfStudents = 80
    • ②下划线
      age_of_oldboy = 56
      number_of_students = 80
      - 变量名 为中文、拼音 = low
      - 变量名过长、词不达意 =low
      - 变量名只能是字母数字或下划线的任意组合
      - 变量名的第一个字符不能是数字
  •   以下关键字不能声明为变量名['and', 'as', 'assert', 'break',    'class',    'continue', 'def', 'del', 'elif', 'else', 'except', 'exec',  'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try','while', 'with', 'yield']   
    
  • 一. python3所有版本 只有int型,python2 中int与long 的区别。  	    
    
  •     二.所有加了引号的字符都是字符串          (无论单引号还是双引号)
     		msg="my name is cobitry,i'm a student"
     		msg1=	
     		'''
     			What is your name?
     			How old are you?
     			Where is your hometown?
     			'''   	     	
    
  •   三. firstname="ab"  lastname="cd" age = 32
    		name=firstname + lastname ( 字符串连接)
    		name=firstname*2   name=abab (字符串复制)
    		name=firstname+ age (报错。 数字与字符串不可连接。 需要用 str() int() 进行转换。)
    
  1. 常量 命名 永远大写。 OLD=10
  2. 输入交互 name= input(" pleast input your name") age = input("How old are you?") hometown =name = input("What is your name?") print("Hello ",name , "your are ", age , "years old, you came from",hometown)
  3. 布尔型(bool)数值 ture false 成立即是真, 不成立就是假。
  4. 代码注释:代码注释分单行和多行注释, 单行注释用#,多行注释可以用三对双引号""" “”"
  5. %s 占位符 print(type(age)) input 输入只有字符型
name = input("Name") 
age = input("Age")
 job = input("Job")
  info ="""
   info of 		%s
   Name: 	   %sAge :    %s
	Job :%s
   end
   """
   %s(name,name,age,job)print(info)

oct 8 进制
hex 16进制
bin 2进制

猜你喜欢

转载自blog.csdn.net/weixin_37361758/article/details/83096328
今日推荐