Chuỗi quấn dòng Python

Mô-đun này cung cấp hai chức năng tiện ích, và cũng như lớp thực hiện tất cả công việc và một chức năng tiện ích. Nếu bạn chỉ gói hoặc điền một hoặc hai chuỗi văn bản, các chức năng tiện lợi sẽ đủ tốt;

Xem thêm

Phiên bản mới nhất của mô-đun textwrap Mã nguồn Python

gói văn bản. bọc[văn bản [ , chiều rộng [ ,. ]]]

Ngắt dòng một đoạn trong văn bản [một chuỗi] sao cho mỗi dòng dài tối đa các ký tự. Tất cả các tùy chọn gói được lấy từ các thuộc tính cá thể của cá thể. Trả về danh sách các dòng đầu ra, không có dòng mới cuối cùng

Các nhà phát triển Python thỉnh thoảng làm việc với các chuỗi. Nhiều tình huống yêu cầu quấn dây để cải thiện khả năng hiển thị hoặc các lý do khác. Các nhà phát triển có thể cần phải ngắt dòng văn bản vì kích thước để tránh tràn vượt quá kích thước của màn hình thường. Các trang web có blog hoặc bài viết cần ngắt dòng văn bản dựa trên kích thước màn hình. Chuỗi gói chỉ dựa trên một số ký tự trên mỗi dòng sẽ dẫn đến việc phá vỡ các từ. Chúng tôi cần một cách để ngắt dòng văn bản để nó không ngắt từ và ngắt dòng trông tự nhiên. Python cung cấp cho chúng tôi một mô-đun có tên là textwrap cho mục đích này. Nó cung cấp các phương pháp khác nhau để bọc văn bản dài. Là một phần của hướng dẫn này, chúng tôi sẽ giải thích bằng các ví dụ đơn giản về cách chúng tôi có thể ngắt dòng văn bản bằng mô-đun textwrap bằng các ví dụ đơn giản

ví dụ 1

Là một phần của ví dụ đầu tiên của chúng tôi, chúng tôi sẽ giải thích cách chúng tôi có thể ngắt dòng văn bản bằng cách sử dụng phương thức quấn[] của mô-đun textwrap

  • quấn [văn bản, chiều rộng = 70] - Phương thức này chấp nhận một chuỗi và bao bọc nó để mỗi dòng có nhiều ký tự nhất được chỉ định bởi tham số chiều rộng. Nó sẽ liệt kê các chuỗi trong đó mỗi mục đại diện cho một dòng. Nó sẽ đảm bảo rằng các từ không bị hỏng. Phương thức này tạo bên trong một thể hiện của lớp TextWrapper chịu trách nhiệm gói văn bản và gọi phương thức wrap[] trên nó. Lớp TextWrapper có nhiều tham số cũng có thể được truyền cho phương thức này. Chúng tôi sẽ giải thích lớp TextWrapper trong các ví dụ sắp tới của chúng tôi

Chúng tôi sẽ sử dụng văn bản Zen of Python [nhập văn bản này] cho các ví dụ của chúng tôi. Mã của chúng tôi cho ví dụ này lưu trữ văn bản trong một biến có tên là dữ liệu. Sau đó, nó ngắt dòng văn bản bằng phương thức quấn[] có chiều rộng mặc định là 70 ký tự. Sau đó, chúng tôi đang kết hợp danh sách được trả về bởi phương thức bằng cách sử dụng phương thức join[] của chuỗi để tạo lại một chuỗi duy nhất từ ​​nó

import textwrap

data = "The Zen of Python, by Tim Peters. Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!"

wrapped_lines = textwrap.wrap[data]
print["Number of Lines : {}".format[len[wrapped_lines]]]

print["\n".join[wrapped_lines]]

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!

ví dụ 2

Là một phần của ví dụ thứ hai, một lần nữa chúng tôi giải thích cách sử dụng phương thức quấn[] với các cài đặt tham số khác nhau

Trước tiên, mã của chúng tôi gọi phương thức quấn [] có chiều rộng 40 ký tự và in kết quả sau khi kết hợp danh sách các chuỗi. Sau đó, nó lại gọi hàm quấn[] với chiều rộng 40 ký tự, dòng tối đa là 12 và một trình giữ chỗ cho các dòng bổ sung dưới dạng chuỗi [. còn tiếp]. Thao tác này sẽ ngắt dòng văn bản có chiều rộng 40 ký tự trên mỗi dòng và sẽ đảm bảo rằng đầu ra có tối đa 12 dòng. Nếu tổng số dòng vượt quá 12 dòng thì nó sẽ bỏ qua các dòng vượt quá 12 dòng và nối thêm [. Còn tiếp] chuỗi ở cuối dòng thứ 12

import textwrap

data = "The Zen of Python, by Tim Peters. Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!"

wrapped_lines = textwrap.wrap[data, width=40]
print["Number of Lines : {}\n".format[len[wrapped_lines]]]

print["\n".join[wrapped_lines]]


wrapped_lines = textwrap.wrap[data, width=40, max_lines=12, placeholder="  [..Continued]"]
print["\nNumber of Lines : {}\n".format[len[wrapped_lines]]]

print["\n".join[wrapped_lines]]

Number of Lines : 23

The Zen of Python, by Tim Peters.
Beautiful is better than ugly. Explicit
is better than implicit. Simple is
better than complex. Complex is better
than complicated. Flat is better than
nested. Sparse is better than dense.
Readability counts. Special cases aren't
special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced. In the face
of ambiguity, refuse the temptation to
guess. There should be one-- and
preferably only one --obvious way to do
it. Although that way may not be obvious
at first unless you're Dutch. Now is
better than never. Although never is
often better than *right* now. If the
implementation is hard to explain, it's
a bad idea. If the implementation is
easy to explain, it may be a good idea.
Namespaces are one honking great idea --
let's do more of those!

Number of Lines : 12

The Zen of Python, by Tim Peters.
Beautiful is better than ugly. Explicit
is better than implicit. Simple is
better than complex. Complex is better
than complicated. Flat is better than
nested. Sparse is better than dense.
Readability counts. Special cases aren't
special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced. In the face
of ambiguity, refuse the  [..Continued]

ví dụ 3

Là một phần của ví dụ thứ ba, chúng tôi sẽ giải thích cách chúng tôi có thể ngắt dòng văn bản bằng phương thức fill[]

  • fill[text,width=70] - Nó hoạt động chính xác như phương thức quấn[] chỉ khác là nó trả về một chuỗi kết hợp từng dòng thay vì trả về danh sách các dòng như quấn[]

Mã của chúng tôi cho ví dụ này hoàn toàn giống với mã của chúng tôi cho ví dụ trước với thay đổi duy nhất là chúng tôi đã sử dụng phương thức fill[] trong ví dụ này thay vì quấn[]

import textwrap

data = "The Zen of Python, by Tim Peters. Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!"

wrapped_data = textwrap.fill[data]

print[wrapped_data]

wrapped_data = textwrap.fill[data, width=40]

print[]
print[wrapped_data]

wrapped_data = textwrap.fill[data, width=40, max_lines=12, placeholder="  [..Continued]"]

print[]
print[wrapped_data]

The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!

The Zen of Python, by Tim Peters.
Beautiful is better than ugly. Explicit
is better than implicit. Simple is
better than complex. Complex is better
than complicated. Flat is better than
nested. Sparse is better than dense.
Readability counts. Special cases aren't
special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced. In the face
of ambiguity, refuse the temptation to
guess. There should be one-- and
preferably only one --obvious way to do
it. Although that way may not be obvious
at first unless you're Dutch. Now is
better than never. Although never is
often better than *right* now. If the
implementation is hard to explain, it's
a bad idea. If the implementation is
easy to explain, it may be a good idea.
Namespaces are one honking great idea --
let's do more of those!

The Zen of Python, by Tim Peters.
Beautiful is better than ugly. Explicit
is better than implicit. Simple is
better than complex. Complex is better
than complicated. Flat is better than
nested. Sparse is better than dense.
Readability counts. Special cases aren't
special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced. In the face
of ambiguity, refuse the  [..Continued]

Ví dụ 4

Là một phần của ví dụ thứ tư, chúng tôi sẽ giải thích cách chúng tôi có thể rút ngắn chuỗi bằng phương thức short[]

  • rút ngắn [văn bản, chiều rộng] - Nó chấp nhận chuỗi và chiều rộng làm đầu vào và kết thúc chuỗi sao cho số lượng ký tự tối đa được chỉ định bởi tham số chiều rộng. Nó đảm bảo rằng các từ không bị hỏng. Nó cũng sử dụng nội bộ đối tượng TextWrapper do đó chấp nhận các đối số được lớp TextWrapper chấp nhận

Mã của chúng tôi cho ví dụ này gọi phương thức rút ngắn [] với các kích thước chiều rộng khác nhau và in chuỗi rút ngắn cuối cùng

import textwrap

data = "The Zen of Python, by Tim Peters. Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!"

wrapped_data = textwrap.shorten[data, width=20]

print["Length of Wrapped Data : {}".format[len[wrapped_data]]]
print[wrapped_data]

wrapped_data = textwrap.shorten[data, width=25]

print["\nLength of Wrapped Data : {}".format[len[wrapped_data]]]
print[wrapped_data]

wrapped_data = textwrap.shorten[data, width=10]

print["\nLength of Wrapped Data : {}".format[len[wrapped_data]]]
print[wrapped_data]

wrapped_data = textwrap.shorten[data, width=50, placeholder="  [...Continued]"]

print["\nLength of Wrapped Data : {}".format[len[wrapped_data]]]
print[wrapped_data]

Length of Wrapped Data : 16
The Zen of [...]

Length of Wrapped Data : 24
The Zen of Python, [...]

Length of Wrapped Data : 9
The [...]

Length of Wrapped Data : 49
The Zen of Python, by Tim Peters.  [...Continued]

Ví dụ 5

Là một phần của ví dụ thứ năm của chúng tôi, chúng tôi sẽ giải thích cách chúng tôi có thể loại bỏ các khoảng trắng ở đầu phổ biến trong văn bản trải rộng trên nhiều dòng bằng phương thức dedent[]

  • dedent[text] - Phương thức này chấp nhận một chuỗi và xóa các khoảng trắng ở đầu phổ biến khỏi chuỗi đó

________số 8_______

Hello All,

How are you?

Regards,
CoderzColumn

Ví dụ 6

Là một phần trong ví dụ thứ sáu của chúng tôi, chúng tôi sẽ giải thích cách chúng tôi có thể thêm chuỗi tiền tố vào các dòng văn bản đã chọn trong đó văn bản được trải rộng trên nhiều dòng bằng cách sử dụng phương thức indent[]

  • indent[text, prefix,predicate=None] - Phương thức này chấp nhận văn bản trải rộng trên nhiều dòng và thêm chuỗi được chỉ định bởi tham số tiền tố ở đầu mỗi dòng. Tham số vị ngữ chấp nhận một hàm lấy làm dòng đơn đầu vào và trả về True nếu tiền tố cần được thêm vào nếu không thì Sai

Mã của chúng tôi cho ví dụ này giải thích cách sử dụng indent[] với các cài đặt tham số khác nhau. Nó cũng giải thích cách chúng ta có thể đặt giá trị cho tham số vị ngữ

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
0

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
1

Ví dụ 7

Là một phần của ví dụ thứ bảy của chúng tôi, chúng tôi sẽ giải thích cách chúng tôi có thể tạo một phiên bản của TextWrapper và sử dụng nó để ngắt dòng văn bản

  • TextWrapper[] - Hàm tạo này tạo một thể hiện của TextWrapper có thể được sử dụng để ngắt dòng văn bản. Dưới đây là danh sách các tham số của hàm tạo
    • chiều rộng - Nó chấp nhận một số chỉ định chiều rộng tối đa của dòng trong ký tự
    • expand_tabs - Nó chấp nhận giá trị boolean. Nếu được đặt thành True sẽ mở rộng các tab thành một danh sách các khoảng trắng
    • tabsize - Nó chấp nhận một số chỉ định số khoảng trắng sẽ được sử dụng cho một tab
    • replace_whitespace - Tham số này chấp nhận giá trị boolean. Nếu nó được đặt thành True thì nó sẽ thay thế ký tự khoảng trắng bằng một khoảng trắng
    • drop_whitespace - Tham số này chấp nhận giá trị boolean. Nếu được đặt thành True thì các khoảng trắng ở đầu và cuối dòng sẽ bị xóa
    • initial_indent - Tham số này chấp nhận một chuỗi sẽ được thêm vào dòng đầu tiên của đầu ra
    • next_indent - Tham số này chấp nhận một chuỗi sẽ được thêm vào trước tất cả các dòng đầu ra ngoại trừ dòng đầu tiên
    • fix_sentence_endings - Tham số này chấp nhận giá trị boolean. Nếu được đặt thành True thì TextWrapper sẽ cố gắng phát hiện phần cuối của câu và đảm bảo rằng các câu được phân tách bằng 2 khoảng trắng
    • break_long_words - Tham số này chấp nhận giá trị boolean. Nếu được đặt thành True thì các từ dài hơn tham số chiều rộng sẽ bị hỏng
    • break_on_hyphens - Tham số này chấp nhận giá trị boolean. Nếu được đặt thành True thì việc ngắt dòng cũng sẽ xảy ra dựa trên dấu gạch ngang
    • max_lines - Nó chấp nhận một số chỉ định số lượng dòng tối đa để giữ trong văn bản được trả về. Nó sẽ bỏ tất cả các dòng ngoài số dòng đó
    • trình giữ chỗ - Nó chấp nhận một chuỗi sẽ được thêm vào cuối dòng văn bản cuối cùng nếu văn bản có nhiều dòng hơn số dòng được chỉ định bởi tham số max_lines

Các phương thức quan trọng của TextWrapper Instance

  • quấn [văn bản] - Phương thức này hoạt động chính xác như phương thức quấn [] đã giới thiệu trước đó nhưng dựa trên cài đặt tham số của phiên bản TextWrapper
  • fill[text] - Phương thức này hoạt động chính xác như phương thức wrap[] đã giới thiệu trước đó nhưng dựa trên cài đặt tham số của đối tượng TextWrapper

Mã của chúng tôi cho ví dụ này bắt đầu bằng cách tạo một phiên bản của TextWrapper. Sau đó, nó in giá trị của tất cả các thuộc tính của thể hiện. Sau đó, nó gọi các phương thức wrap[] và fill[] để giải thích cách sử dụng của chúng

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
2

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
3

Ví dụ 8

Là một phần trong ví dụ thứ tám của chúng tôi, chúng tôi đang trình bày cách chúng tôi có thể đặt các giá trị tham số khác nhau của phiên bản TextWrapper. Sau đó, chúng tôi cũng đang gói dữ liệu bằng cách sử dụng phiên bản này để hiển thị tác động của các tham số đối với văn bản được bọc

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
4

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
5

Ví dụ 9

Là một phần trong ví dụ thứ chín của chúng tôi, một lần nữa chúng tôi sẽ trình bày cách chúng tôi có thể đặt các giá trị tham số khác nhau của phiên bản TextWrapper. Sau đó, chúng tôi cũng đang gói dữ liệu bằng cách sử dụng phiên bản này để hiển thị tác động của các tham số đối với văn bản được bọc

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
6

Number of Lines : 13
The Zen of Python, by Tim Peters. Beautiful is better than ugly.
Explicit is better than implicit. Simple is better than complex.
Complex is better than complicated. Flat is better than nested. Sparse
is better than dense. Readability counts. Special cases aren't special
enough to break the rules. Although practicality beats purity. Errors
should never pass silently. Unless explicitly silenced. In the face of
ambiguity, refuse the temptation to guess. There should be one-- and
preferably only one --obvious way to do it. Although that way may not
be obvious at first unless you're Dutch. Now is better than never.
Although never is often better than *right* now. If the implementation
is hard to explain, it's a bad idea. If the implementation is easy to
explain, it may be a good idea. Namespaces are one honking great idea
-- let's do more of those!
7

Điều này kết thúc hướng dẫn nhỏ của chúng tôi giải thích cách chúng tôi có thể ngắt dòng văn bản dài đúng cách bằng cách sử dụng mô-đun textwrap của Python. Xin vui lòng cho chúng tôi biết quan điểm của bạn trong phần bình luận

Chủ Đề