end和sep的使用方法


end: 默認是換行'\n',表示以什么結尾,比如以, | \n 等
方法:

默認end = '\n'
a
b
c
如果end = ' '
a b c

sep: 默認是空格' ' 表示兩個字符之間用什么隔開,如, : |等
方法:

sep = ','
老板,root,12

sep = '|'
老板|root|12

說實話以上也看不出什么來.二者效果區別如下:

sep = '|'
name = input('name:')
age = input('age:')
print(name,age,sep='|')
輸出結果:
name:root
age:123
root|123 # 看我

end = '|'
name = input('name:')
age = input('age:')
print(name,age,end='|')
輸出結果:
name:root
age:123
root 123| #看我


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM