sep='' liên quan đến một chức năng xem xét đặt đối số được đặt tên sep thành một chuỗi chưa được điền. Xem print[] hoạt động; . Mặc định là khoảng trắng [sep=' '], lệnh gọi hàm này đảm bảo rằng không có khoảng cách giữa phí Thuộc tính. $ và giá trị dấu phẩy động thuế có tổ chức.
Nhìn vào đầu ra của ba lệnh gọi print[] sau đây để thấy sự khác biệt
>>> in['foo', 'thanh']
thanh foo
>>> print['foo', 'bar', sep='']
foobar
>>> print['foo', 'bar', sep=' -> ']
foo -> thanh
giá trị đối số sep đã thay đổi mọi thứ
Sử dụng \t hoặc dấu cách làm dấu ngăn cách in sẽ cho thấy sự khác biệt
>>> print['trứng', 'giăm bông']
trứng giăm bông
>>> print['trứng', 'giăm bông', sep='\t']
trứng giăm bông
Quan tâm để tìm hiểu python một cách chi tiết?
Dấu phân cách giữa các đối số của hàm print[] trong Python theo mặc định là khoảng trắng [tính năng không gian mềm], có thể được sửa đổi và có thể được tạo thành bất kỳ ký tự, số nguyên hoặc chuỗi nào theo lựa chọn của chúng tôi. Tham số 'sep' được sử dụng để đạt được điều tương tự, nó chỉ được tìm thấy trong python 3. x trở lên. Nó cũng được sử dụng để định dạng các chuỗi đầu ra
ví dụ
GFG 09-12-2016 [email protected]4
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]7
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]9
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]7
GFG 09-12-2016 [email protected]0
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]2
GFG 09-12-2016 [email protected]3
GFG 09-12-2016 [email protected]4
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]7
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]9
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]41
GFG 09-12-2016 [email protected]0
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]44
GFG 09-12-2016 [email protected]45
GFG 09-12-2016 [email protected]3
GFG 09-12-2016 [email protected]47
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]50
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]52
GFG 09-12-2016 [email protected]0
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]55
GFG 09-12-2016 [email protected]45
đầu ra
GFG 09-12-2016 [email protected]
Tham số sep khi được sử dụng với tham số kết thúc, nó tạo ra kết quả tuyệt vời. Một số ví dụ bằng cách kết hợp tham số sep và end
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]7
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]9
GFG 09-12-2016 [email protected]0
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]64
GFG 09-12-2016 [email protected]65
GFG 09-12-2016 [email protected]66
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]7
GFG 09-12-2016 [email protected]45
GFG 09-12-2016 [email protected]71
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]7
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]9
GFG 09-12-2016 [email protected]0
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]44
GFG 09-12-2016 [email protected]80
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]82
GFG 09-12-2016 [email protected]45
GFG 09-12-2016 [email protected]3
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]87
GFG 09-12-2016 [email protected]8
GFG 09-12-2016 [email protected]89
GFG 09-12-2016 [email protected]0
GFG 09-12-2016 [email protected]1
GFG 09-12-2016 [email protected]64
GFG 09-12-2016 [email protected]65
GFG 09-12-2016 [email protected]94
GFG 09-12-2016 [email protected]5
GFG 09-12-2016 [email protected]6
GFG 09-12-2016 [email protected]52
GFG 09-12-2016 [email protected]45
đầu ra
br>GFG 09-12-2016 [email protected]
Ghi chú. Vui lòng thay đổi ngôn ngữ từ Python sang Python 3 trong ý tưởng trực tuyến
Chuyển đến ý tưởng python tương tác của bạn bằng cách nhập python vào cmd [ windows ] hoặc terminal [ linux ]
GFG 09-12-2016 [email protected]99
GFG 09-12-2016 [email protected]80
GFG 09-12-2016 [email protected]81
GFG 09-12-2016 [email protected]82
Vui lòng viết bình luận nếu bạn thấy bất cứ điều gì không chính xác hoặc bạn muốn chia sẻ thêm thông tin về chủ đề thảo luận ở trên