Devdit
 

Python int to string ด้วยคำสั่ง str

889

สอนเขียนภาษา Python เพื่อแปลง int เป็น string ด้วยคำสั่ง str โดยคำสั่งนี้จะต้องระบุตัวแปรที่ต้องการแปลงเป็นชนิดข้อความ (String) เป็น argument สามารถเขียนโปรแกรมได้ดังนี้

 

ตัวอย่าง Python int to string ด้วยคำสั่ง str

i = 30
print( type(i), i )
i = str(i)
print( type(i), i )

ผลลัพธ์

<class 'int'> 30
<class 'str'> 30
แก้ไข 2 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ