01/10/2018, 09:04
In f-string python theo Learn Python the Hard Way
https://learnpythonthehardway.org/book/ex24.html
trong đó có 1 đoạn code nó in ra như vậy?
We can also do that this way:
We'd have 500000 beans, 500 jars, and 5 crates.
đây là đoạn code mình sửa lại theo pep 498
print ("We can also do that this way:")
print (f"We'd have {secret_formula(start_point)} beans, {secret_formula(start_point)} jars, and {secret_formula(start_point)} crates.")
nó lại in ra như vậy
We can also do that this way:
We'd have (500000, 500, 5) beans, (500000, 500, 5) jars, and (500000, 500, 5) crates.
Bài liên quan
Đoạn code trước khi print:
Nên nếu bạn dùng
thì nó sẽ chạy code
Và hàm
secret_formular
thì trả về một tuple 3 phần tử, nên bạn nhận được(500000, 500, 5)
là đúng rồi.