python-1day
生活随笔
收集整理的這篇文章主要介紹了
python-1day
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python筆記
<head> 打印命令 print
----print 打印命令------
定義變量格式 XXX = ("XXX")
引用格式1:print(XXX)
引用格式2:print('輸入任何內容加引號',XXX)打印字符類型
print(type(XXX))實驗
name = "Hello World!"
print(name)
print('my name is',name)
返回結果
Hello World!
my name is Hello World!
------------------------------
</head>
<head> 交互式輸入 input
AAA = input("AAA:")
BBB = input("BBB:")
print(AAA,BBB)</head>
<head> 格式打印
#%s (全拼string) (驗證字符)
#%d 整數 (驗證整數)檢測驗證數據類型 錯誤則報錯
#%f 浮點數
.format 格式2、3 指定{}中內容=某個變量---------格式打印1-------------
AAA = '111'
BBB = '222'
CCC = '333'test = '''
%s
%s
%s
'''%(AAA,BBB,CCC)
print(test)實驗
name = 'gaoliandi'
ago = '30'
work = 'IT'info = '''
%s
%s
%s
'''%(name,ago,work)
print(info)--------格式打印2--------------
AAA = '111'
BBB = '222'
CCC = '333'test = '''
{aaa}
{bbb}
{ccc}
'''.format(aaa=AAA,bbb=BBB,ccc=CCC)
print(test)--------格式打印3--------------
AAA = '111'
BBB = '222'
CCC = '333'test = '''
{0}
{1}
{2}
'''.format(AAA,BBB,CCC)
print(test)</head>
<head> 字符轉換 int str
int(XXX) 轉化整數
str(XXX) 轉化字符</head>
<head> 利用交互式輸入賬戶密碼(加密) 判斷賬戶密碼是否正確
筆記
import getpass 調用getpass模塊 import加載模塊命令
模板 password = getpass.getpass("password:")
if (判斷條件,不縮進) 子命令行必須縮進
else: (否則執行條件,不縮進) 子命令行必須縮進實驗
import getpass
_username = "gaoliandi"
_password = "abc123"
username = input("username:")
password = getpass.getpass("password:")if _username == username and _password == password:print('Welcone user {name} login...'.format(name=username))
else:print("Invalid username or password!")</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
<head>
</head>
?
轉載于:https://www.cnblogs.com/gaoshuji/p/7771779.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的python-1day的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python列表的append/ente
- 下一篇: 如何快速入手一个JavaWeb项目