Ainsteinx Logo
Ainsteinx
👤
Welcome to Ainsteinx
Login

Change Language

Currency

Home
Blog
Services
ທຸກບົດຮຽນ
EP.8 Python ສຳລັບຄົນ Laos

f-strings: put variables inside text

name = "ນາງ ແກ້ວ"
price = 125000

print(f"ສະບາຍດີ {name}!")
print(f"ລາຄາ {price:,} ກີບ")
Video coming soon
EP.8 ເຄັດລັບ

f-strings: put variables inside text

The trick Python programmers use every day.

ໃສ່ f ໄວ້ໜ້າເຄື່ອງໝາຍ " ແລ້ວຂຽນຕົວແປໃນ { } ໄດ້ເລີຍ.

ໃນ { } ຍັງຄິດໄລ່ ແລະ ຈັດຮູບແບບໄດ້ ເຊັ່ນ {price:,} ໃສ່ຈຸດຂັ້ນຫຼັກພັນ.

ep08-f-strings.py
name = "ນາງ ແກ້ວ"
price = 125000

print(f"ສະບາຍດີ {name}!")
print(f"ລາຄາ {price:,} ກີບ")

ຜົນລັບ

ສະບາຍດີ ນາງ ແກ້ວ!
ລາຄາ 125,000 ກີບ
  • #PythonສຳລັບຄົນLaos
  • #Python
  • #ຮຽນໂປຣແກຣມ
  • #ບອກຕໍ່ຄວາມຮູ້
  • #shorts