1. 程式人生 > >python-day7--%s與%d的使用,python2中的input及raw_input

python-day7--%s與%d的使用,python2中的input及raw_input

print raw 顏色 name msg 使用 input python pytho

#coding:utf-8   #python2中顯示中文
#%s %d
# name=‘egon‘
# age=18
# print(‘my name is‘,name)
# print(‘my name is my age is‘,name,age)
#%s既能接收字符串,也能接收數字
# print(‘my name is %s my age is %s‘ %(name,age))

#%d只能接收數字
# print(‘\033[45mmy name is %s my age is %d\033[0m‘ %(name,age)) # \033[45m \033[0m 調整輸出顏色
# print(‘my name is \033[45m%s\033[0m my age is \033[46m%d\033[0m‘ %(name,age))


# msg=‘‘‘
# ------%s info------
# name:%s
# age:%s
# sex:%s
# height:%s
# ---------------------
# ‘‘‘ %(‘alex‘,‘alex‘,18,‘female‘,165)
# print(msg)


# while True:
# name=input(‘name: ‘)
# age=input(‘age: ‘)
# sex=input(‘sex: ‘)
# height=input(‘height: ‘)
# msg=‘‘‘
# ------%s info------
# name:%s
# age:%s
# sex:%s
# height:%s
# ---------------------
# ‘‘‘ %(name,name,age,sex,height)
# print(msg)






#python2 的input 與raw_input
#python3只有input
# x=raw_input(‘>>: ‘) #python2的raw_input與python3的input的一樣的
# print(x,type(x))

# x=input(‘>>: ‘) #python2的input,用戶輸入什麽類型,就原封不動的存成什麽類型
# print(x,type(x))

python-day7--%s與%d的使用,python2中的input及raw_input