“cara menulis ulang file dalam python” Kode Jawaban

Python menulis untuk mengajukan

file = open(“testfile.txt”,”w”) 
 
file.write(“Hello World”) 
file.write(“This is our new text file”) 
file.write(“and this is another line.”) 
file.write(“Why? Because we can.”) 
 
file.close() 
Misty Macaw

Buka file teks di Python

f=open("Diabetes.txt",'r')
f.read()
Grieving Goshawk

cara menulis ulang file dalam python

def baseboard(width, length, baseboardcost):
    perimeter = 2 * (length + width)
    return perimeter * baseboardcost

def carpet(width, length, carpetcost):
    return width * length * carpetcost
width = float(input('What is the width of the room? (ft) '))
length = float(input('What is the length of t5he room? (ft) '))
totalbaseboardcost = float(input('Input the cost of a linear foot of baseboard ($) '))
carpetcost = float(input('Input the cost of a square foot of carpet($) '))
totalcost = baseboard(width, length, totalbaseboardcost) + carpet(width, length, carpetcost) + 500
print ('For a room of width',width,'and length',length,'the cost of the reno is $',totalcost,)
Keorify

Jawaban yang mirip dengan “cara menulis ulang file dalam python”

Pertanyaan yang mirip dengan “cara menulis ulang file dalam python”

Lebih banyak jawaban terkait untuk “cara menulis ulang file dalam python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya