Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个简单的控件,它显示一段文本,其中的内容、大小、位置等是通过 Python 控制的。有没有办法在给定宽度的情况下计算控件的准确高度?
现在我正在做:
a = total_number_of_characters_in_string b = max_number_of_characters_in_a_line h = a/b
但问题不是每一行都被填满,而且还有换行符。
有没有一种简单的方法可以做到这一点?